用div锁定页面
var sWidth,sHeight;
sWidth=screen.width;
sHeight=screen.height;
mleft=(sWidth-820)/2-10;
bgObj=parent.document.createElement( "div ");
bgObj.setAttribute( 'id ', 'bgDiv ');
bgObj.setAttribute( "align ", "center ");
bgObj.style.position= "absolute ";
bgObj.style.top= "0 ";
bgObj.style.background= "#cccccc ";
bgObj.style.filter= "progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75 ";
bgObj.style.opacity= "0.6 ";
bgObj.style.left=mleft+ "px ";
bgObj.style.width=820 + "px ";
bgObj.style.height=520 + "px ";
bgObj.style.zIndex = "10000 ";
parent.document.body.appendChild(bgObj);
1)两个问题
mleft=(sWidth-820)/2-10
我用绝对位置,因为页面居中,我首先算出left的宽度,上面的10是垂直滚动条的宽度,我如何判断这时有出现滚动条呢??我在csdn上看到
var h=document.body.scrollHeight;
var h1=document.body.clientHeight;
if(h> h1)
alert( "有滚动条 ");
可是实际上我是h <h1
2)如果用div的相对位置能锁定页面吗?该如何处理
------解决方案--------------------你所指的锁定页面是什么意思?
像163邮箱那样吗