哥哥,不行呀,还是不行!
<script>
function alertCenter()
{
//其中alterLayer是要居中的div的id
var cWidth=document.documentElement.clientWidth;
var cHeight=document.documentElement.clientHeight;
var acHeight=alertLayer.clientHeight;
var acWidth=alertLayer.clientWidth;
var sLeft=document.documentElement.scrollLeft;
var sTop=document.documentElement.scrollTop;
alertLayer.style.left=(cWidth-acWidth)/2+sLeft+"px";
alertLayer.style.top=(cHeight- acHeight)/2+sTop-50+"px";
}
</script>
<body onLoad="alertCenter();">
<div id="alertLayer">
<a href="pic/201082792763.jpg" rel="lightbox" ><img src="pic/201082792763.jpg" width="134" height="97" style="border:1 solid #ffffff" ></a>
</div>