未测试,仅供参考:
obj/需要定位的对象;
father/定位对象的父级元素;
居中的算法:obj.style.left=father.currentStyle.offsetWidth/2-obj.currentStyle.offsetWidth/2;
obj.style.top=fathre.currentStyle.offsetHeight/2-obj.currentStyle.offsetHeight/2遮罩可以这样试试:设置层高宽够大,一直大到再大1个单位就会出现滚动条,另设置zInex足够大,最后,“再用serTimeOut防止用户滚动屏幕”,好像应该是让用它来设置你的层跟随滚动吧!?
obj/需要定位的对象;
father/定位对象的父级元素;
居中的算法:obj.style.left=father.currentStyle.offsetWidth/2-obj.currentStyle.offsetWidth/2;
obj.style.top=fathre.currentStyle.offsetHeight/2-obj.currentStyle.offsetHeight/2遮罩可以这样试试:设置层高宽够大,一直大到再大1个单位就会出现滚动条,另设置zInex足够大,最后,“再用serTimeOut防止用户滚动屏幕”,好像应该是让用它来设置你的层跟随滚动吧!?
这个方法我也试过
但是如何判断“再大1个单位就会出现滚动条”
如果层不小心设置的过大一点,出现滚动条之后用户再向下拉滚动条,因为我用setTimeOut设置了层跟随滚动,所以页面又会因为层而增大,到最后无限大下去,很难看因为把层的右下脚和屏幕的右下脚对齐时,不论层有多高多宽,层的左边和上边left和top都允许出现负值,所以不会产生新的滚动条。就解决了无限大的问题。现在就时不知道如何实现右下角对齐
使用currentStyle提示参数无效
father.offsetWidth
除了这个基本没什么别的办法。http://www.cnblogs.com/0009/archive/2007/04/30/733737.html
我这个就是用popup做的
使用document.body.clientHeight不行么?偶一直都用的好好的啊。
不管跟不跟随,也不管拖不拖动滚动条都一样,不过缺点是层不能放在框架中。
我一般都是window.top.document.write(t),这样就不会有问题了。
另外我一般会在module中放一个等大的iframe,否则遮不住列表框的。
<head runat="server">
<title>无标题页</title>
<link href="../Include/Style/Style.css" type="text/css" rel="stylesheet">
<script type="text/javascript">
function showpan()
{
var x=document.getElementById("d1").style.left;
var y=document.getElementById("d1").style.top;document.getElementById("univlist").style.left =x;
document.getElementById("univlist").style.top = y;document.getElementById("univlist").style.display = "block";
}
</script>
</head>
<body>
<form id="form1" runat="server">
<table cellspacing="0" cellpadding="0" width="100%" border="1">
<tr>
<td height="60"> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td id="d1"><input type="text" id="tb" onclick="showpan()"/></td>
</tr>
<tr>
<td style="height:100px" colspan="2"><DIV id="univlist" style="position:relative;z-index:30;display:none;">
<LI class="active" id="c_0"><A
href="http://reg.xiaonei.com/register.do#">中国</A> </LI>
<LI id="c_7"><A o
href="http://reg.xiaonei.com/register.do#">美国</A> </LI>
<LI id="c_6"><A
href="http://reg.xiaonei.com/register.do#">加拿大</A> </LI>
<LI id="c_5"><A
href="http://reg.xiaonei.com/register.do#">英国</A> </LI>
<LI id="c_1"><A
href="http://reg.xiaonei.com/register.do#">澳大利亚</A> </LI>
<LI id="c_2"><A
href="http://reg.xiaonei.com/register.do#">法国</A> </LI>
<LI id="c_8"><A
href="http://reg.xiaonei.com/register.do#">德国</A> </LI>
<LI id="c_4"><A
href="http://reg.xiaonei.com/register.do#">新西兰</A> </LI>
<LI id="c_3"><A
href="http://reg.xiaonei.com/register.do#">新加坡</A> </LI></UL>
</DIV></td>
</tr>
</table> </form>
</body>
</html>
帮你改好了!