📄 dhtml.js
字号:
//Inputs: vObject - object name or object reference
//Outputs: object reference.
//*********************************************************************************************
if (typeof vObject == 'string') {
if (bIsIE4)
return eval("document.all." + vObject);
else if (bIsW3C)
return document.getElementsByName(vObject);
else
if (document.layers[vObject])
return document.layers[vObject];
else
return eval("document." + vObject);
}
else {
return vObject;
}
}
function getObjectsbyTag(vObject) {
//*********************************************************************************************
//Purpose: Return an object reference
//Inputs: vObject - object name or object reference
//Outputs: object reference.
//*********************************************************************************************
if (typeof vObject == 'string') {
if (bIsIE4)
return eval("document.all.tags('" + vObject+ "')");
else if (bIsW3C)
return document.getElementsByTagName(vObject);
}
else {
return vObject;
}
}
function getObjStyle(vObject) {
//*********************************************************************************************
//Purpose: Return a reference to an objects style property
//Inputs: vObject - object name or reference
//Outputs: style reference.
//*********************************************************************************************
if (bIsIE4 || bIsW3C)
return getObj(vObject).style;
else
return getObj(vObject);
}
function getClientWidth() {
//*********************************************************************************************
//Purpose: Return the ClientWidth
//Inputs: None.
//Outputs: integer.
//*********************************************************************************************
if (bIsDHTML) {
if (bIsIE4) {
return document.body.clientWidth;
} // else is NN4 && W3C
return innerWidth;
}
return 0;
}
function getClientHeight() {
//*********************************************************************************************
//Purpose: Return the ClientHeight
//Inputs: None.
//Outputs: integer.
//*********************************************************************************************
if (bIsDHTML) {
if (bIsIE4) {
return document.body.clientHeight;
} // else bIsNN4 && W3C
return innerHeight;
}
return 0;
}
function getObjWidth(vObject) {
//*********************************************************************************************
//Purpose: Return the computed width of an object
//Inputs: Object name or object reference..
//Outputs: integer.
//*********************************************************************************************
if (bIsDHTML) {
var obj = getObj(vObject);
if (bIsIE4) {
return obj.offsetWidth;
} else if (bIsW3C) {
return parseInt(document.defaultView.getComputedStyle(obj, "").getPropertyValue("width"));
} else { // else bIsNN4
return obj.clip.width;
}
}
return 0;
}
function getObjHeight(vObject) {
//*********************************************************************************************
//Purpose: Return the computed height of an object
//Inputs: Object name or object reference..
//Outputs: integer.
//*********************************************************************************************
if (bIsDHTML) {
var obj = getObj(vObject);
if (bIsIE4) {
return obj.offsetHeight;
} else if (bIsW3C) {
return parseInt(document.defaultView.getComputedStyle(obj, "").getPropertyValue("height"));
} else { // else is NN4
return obj.clip.height;
}
}
return 0;
}
function getObjTop(vObject) {
//*********************************************************************************************
//Purpose: Return the computed top value of an object
//Inputs: Object name or object reference.
//Outputs: integer.
//*********************************************************************************************
if (bIsDHTML) {
var obj = getObj(vObject);
if (bIsIE4) {
return obj.style.pixelTop;
} else if (bIsW3C) {
return parseInt(document.defaultView.getComputedStyle(obj, "").getPropertyValue("top"));
} else { // else is NN4
return obj.top;
}
}
return 0;
}
function getObjSumTop(vObject) {
//*********************************************************************************************
//Purpose: Return the computed top value of an object, regardless of
// element containers. NOTE: This is really only needed for
// IE as N6 does this automatically and NN4X doesn't do it at all.
//Inputs: Object name or object reference.
//Outputs: integer.
//*********************************************************************************************
if (bIsDHTML) {
var obj = getObj(vObject);
var lTop = 0;
if (bIsIE4 || bIsW3C) {
for (var i=0; (obj); i++) {
lTop += obj.offsetTop;
obj = obj.offsetParent;
}
return lTop;
} else {
return getObjTop(vObject);
}
}
return 0;
}
function getObjLeft(vObject) {
//*********************************************************************************************
//Purpose: Return the computed left value of an object
//Inputs: Object name or object reference.
//Outputs: integer.
//*********************************************************************************************
if (bIsDHTML) {
var obj = getObj(vObject);
if (bIsIE4) {
return obj.style.pixelLeft;
} else if (bIsW3C) {
return parseInt(document.defaultView.getComputedStyle(obj, "").getPropertyValue("left"));
} else { // else is NN4
return obj.left;
}
}
return 0;
}
function getObjSumLeft(vObject) {
//*********************************************************************************************
//Purpose: Return the computed left value of an object, regardless of
// element containers. NOTE: This is really only needed for
// IE as N6 does this automatically and NN4X doesn't do it at all.
//Inputs: Object name or object reference.
//Outputs: integer.
//*********************************************************************************************
if (bIsDHTML) {
var obj = getObj(vObject);
var lLeft = 0;
if (bIsIE4 || bIsW3C) {
for (var i=0; (obj); i++) {
lLeft += obj.offsetLeft;
obj = obj.offsetParent;
}
return lLeft;
} else { // else is NN4
return getObjLeft(vObject);
}
}
return 0;
}
function clearObjHeight(vObject) {
if (bIsDHTML) {
var obj = getObj(vObject);
if (bIsIE4) {
obj.style.height = '';
} else if (bIsW3C) {
obj.style.height = '';
} else { // is NN4
if (document.layers[obj.id])
document.layers[obj.id].clip.height = '';
else
obj.clip.height = '';
}
}
}
function clearObjWidth(vObject) {
if (bIsDHTML) {
var obj = getObj(vObject);
if (bIsIE4) {
obj.style.width = '';
} else if (bIsW3C) {
obj.style.width = '';
} else { // is NN4
if (document.layers[obj.id])
document.layers[obj.id].clip.width = '';
else
obj.clip.width = '';
}
}
}
function setObjHeight(vObject, iHeight) {
//*********************************************************************************************
//Purpose: Set the height of an object
//Inputs: vObject - Object name or object reference, iNewHeight - the new height for this object..
//Outputs: None.
//*********************************************************************************************
if (bIsDHTML) {
var obj = getObj(vObject);
var iNewHeight = parseInt(iHeight);
if (!isNaN(iNewHeight)) {
if (bIsIE4) {
obj.style.height= iNewHeight;
} else if (bIsW3C) {
obj.style.height = iNewHeight + "px";
} else { // is NN4
if (document.layers[obj.id])
document.layers[obj.id].clip.height = iNewHeight;
else
obj.clip.height = iNewHeight;
}
}
}
}
function setObjWidth(vObject, iWidth) {
//*********************************************************************************************
//Purpose: Set the width of an object
//Inputs: vObject - Object name or object reference, iNewWidth - the new width for this object..
//Outputs: None.
//*********************************************************************************************
if (bIsDHTML) {
var obj = getObj(vObject)
var iNewWidth = parseInt(iWidth);
if (!isNaN(iNewWidth)) {
if (bIsIE4) {
obj.style.width = iNewWidth;
} else if (bIsW3C) {
obj.style.width = iNewWidth + "px";
} else { // is NN4
if (document.layers[obj.id])
document.layers[obj.id].clip.width = iNewWidth;
else
obj.clip.width = iNewWidth;
}
}
}
}
function moveObjTo(vObject, iX, iY) {
//*********************************************************************************************
//Purpose: Move an object to given coordinates
//Inputs: vObject - Object name or object reference, x - the left coordinate, y - the top coordinate.
//Outputs: None.
//*********************************************************************************************
if (bIsDHTML) {
var obj = getObj(vObject);
var x = parseInt(iX);
var y = parseInt(iY);
if (!isNaN(x) && !isNaN(y)) {
if (bIsIE4 || bIsW3C) {
obj.style.left = x + "px";
obj.style.top = y + "px";
} else {
document.layers[obj.id].left = x;
document.layers[obj.id].top = y;
}
}
}
}
function hideObj(vObject) {
//*********************************************************************************************
//Purpose: Set an objects visibility property to hidden.
//Inputs: vObject - Object name or object reference
//Outputs: None.
//*********************************************************************************************
if (bIsDHTML) {
var obj = getObj(vObject);
if (obj) {
if (bIsIE4 || bIsW3C) {
obj.style.visibility = "hidden";
} else {
document.layers[obj.id].visibility = "hide";
}
}
}
}
function showObj(vObject) {
//*********************************************************************************************
//Purpose: Set an objects visibility property to visible.
//Inputs: vObject - Object name or object reference
//Outputs: None.
//*********************************************************************************************
if (bIsDHTML) {
var obj = getObj(vObject);
if (bIsIE4 || bIsW3C) {
obj.style.visibility = "visible";
} else {
document.layers[obj.id].visibility = "show";
}
}
}
function displayObj(vObject) {
//*********************************************************************************************
//Purpose: Force a named object into the document flow (does not work in NN4)
//Inputs: vObject - Object name or object reference
//Outputs: None.
//*********************************************************************************************
if (bIsDHTML) {
if (bIsIE4 || bIsW3C) {
obj = getObj(vObject);
obj.style.display = "block";
}
showObj(vObject);
}
}
function removeObj(vObject) {
//*********************************************************************************************
//Purpose: Remove a named object from the document flow (does not work in NN4)
//Inputs: vObject - Object name or object reference
//Outputs: None.
//*********************************************************************************************
if (bIsDHTML) {
if (bIsIE4 || bIsW3C) {
obj = getObj(vObject);
obj.style.display = "none";
}
hideObj(vObject);
}
}
function getColor(vObject) {
//*********************************************************************************************
//Purpose: Return the foreground color of an object.
//Inputs: vObject - Object name or object reference.
//Outputs: String - the objects foreground color
//*********************************************************************************************
if (bIsDHTML) {
var obj = getObj(vObject);
if (bIsIE4)
return obj.style.color;
else if (bIsW3C)
return obj.style.color;
else
return '';
}
}
function setColor(vObject, sColor) {
//*********************************************************************************************
//Purpose: Set the foreground color of an object.
//Inputs: vObject - Object name or object reference, sColor - New color for the object.
//Outputs: None.
//*********************************************************************************************
if (bIsDHTML) {
var obj = getObj(vObject);
if (bIsIE4)
obj.style.color = sColor;
else if (bIsW3C)
obj.style.color = sColor;
}
}
function parseHex(iDecimalValue) {
//*********************************************************************************************
//Purpose: Convert a decimal value to hex
//Inputs: iDecimalValue - the decimal value for conversion..
//Outputs: Return the hex value.
//*********************************************************************************************
var aHexadecimalValues = ['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'];
if (iDecimalValue > 16)
return parseHex(Math.floor(iDecimalValue / 16)) + '' + aHexadecimalValues[iDecimalValue % 16];
else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -