把顯示層顯示在屏幕中間orm
function OpenWin(divWin, divBody)
{
document.getElementById(divWin).style.display="block"
document.getElementById(divBody).style.display="block"
}
function CloseWin(divWin, divBody)
{
document.getElementById(divWin).style.display="none"
document.getElementById(divBody).style.display="none"
}
// Example: obj = findObj("image1");
function findObj(theObj, theDoc)
{
var p, i, foundObj;
if(!theDoc) theDoc = document;
if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
{
theDoc = parent.frames[theObj.substring(p+1)].document;
theObj = theObj.substring(0,p);
}
if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
for (i=0; !foundObj && i < theDoc.forms.length; i++)
foundObj = theDoc.forms[i][theObj];
for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++)
foundObj = findObj(theObj,theDoc.layers[i].document);
if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
return foundObj;
}server
//將懸浮層的位置定位在屏幕中央
function GetCenterXY_ForLayer(objdiv)
{
x = document.body.scrollLeft;
y = document.body.scrollTop;
//獲取屏幕寬度
availWidth = parseInt(window.screen.availWidth);
availHeight = parseInt(window.screen.availHeight);
tblWidth = parseInt(objdiv.style.width);
y = y + availHeight/4;
x = (availWidth - tblWidth)/2 - 300;
objdiv.style.top = y;
objdiv.style.left = x;
}
// 將層的高度和寬度設置爲屏幕的高度和寬度
function GetHW(obj)
{
obj.style.height = document.body.scrollHeight;
obj.style.width = document.body.scrollWidth;
}htm
<body onload='GetCenterXY_ForLayer(findObj("divInfo")); GetHW(findObj("divBody")); GetHW(findObj("f"));'>ci
在body中寫:get
<div style="Z-INDEX: 9998; POSITION: absolute; FILTER: alpha(Opacity=40); BACKGROUND-COLOR: black; WIDTH: 0px; DISPLAY: none; HEIGHT: 0px; TOP: 0px; LEFT: 0px"
id="divBody" runat="server"><iframe style="WIDTH: 1px; HEIGHT: 1px" id="f" src="../../../BackGround.htm"></iframe>
</div>iframe
要顯示的層:string
<div style="Z-INDEX: 9999; BORDER-BOTTOM: #003399 1px solid; POSITION: absolute; BORDER-LEFT: #003399 1px solid; BACKGROUND-COLOR: white; WIDTH: 500px; DISPLAY: none; HEIGHT: 300px; BORDER-TOP: #003399 1px solid; BORDER-RIGHT: #003399 1px solid"
id="divInfo" runat="server">it