![]() |
#2
pigzee2010-10-10 17:10
|

//创建一个遮罩层
function Layer(w,htmlContent)
{
//创建一个遮罩层,半透明
//------------------我是谁?我是割线!-----------------//
var lay = document.createElement("div");
lay.id = "frame"
with(lay.style)
{
width = "100%";
height = document.body.scrollHeight + 100 + "px";
background = "#000000";
position = "absolute";
left = "0";
top = "0";
filter = 'Alpha(opacity=50)';
opacity = '0.5';
}
document.body.appendChild(lay);
//创建显示内容
var info = document.createElement("div");
info.id = "msg";
info.innerHTML = htmlContent;
with(info.style)
{
position = "absolute";
left = (document.body.offsetWidth - w) / 2 + "px";
top = document.documentElement.scrollTop + window.screen.height / 6 + "px";
}
document.body.appendChild(info);
hiddenSelect("hidden"); //隐藏下拉菜单
}
js的弹层,层里的内容如何定位在屏幕的正中央啊。function Layer(w,htmlContent)
{
//创建一个遮罩层,半透明
//------------------我是谁?我是割线!-----------------//
var lay = document.createElement("div");
lay.id = "frame"
with(lay.style)
{
width = "100%";
height = document.body.scrollHeight + 100 + "px";
background = "#000000";
position = "absolute";
left = "0";
top = "0";
filter = 'Alpha(opacity=50)';
opacity = '0.5';
}
document.body.appendChild(lay);
//创建显示内容
var info = document.createElement("div");
info.id = "msg";
info.innerHTML = htmlContent;
with(info.style)
{
position = "absolute";
left = (document.body.offsetWidth - w) / 2 + "px";
top = document.documentElement.scrollTop + window.screen.height / 6 + "px";
}
document.body.appendChild(info);
hiddenSelect("hidden"); //隐藏下拉菜单
}
left = (document.body.offsetWidth - w) / 2 + "px";
top = document.documentElement.scrollTop + window.screen.height / 6 + "px";
左,上
这两个根据传入的htmlContent内容不固定的,宽高度不相同。