<body>
<div id="test" style="position:absolute;background-color:Gray;width:100px;height:100px"></div>
<div style="height:1800px"></div>
<script>
function locateCenter()
{
var temp=document.getElementById("test");
var now=new Date();
temp.style.pixelTop=Math.round((document.body.clientHeight-100)/2)+document.body.scrollTop;
temp.style.pixelLeft=Math.round((document.body.clientWidth-100)/2);
temp.innerHTML=now.getTime();
}
locateCenter();
window.onscroll=locateCenter;
</script>
</body>
<div id="test" style="position:absolute;background-color:Gray;width:100px;height:100px"></div>
<div style="height:1800px"></div>
<script>
function locateCenter()
{
var temp=document.getElementById("test");
var now=new Date();
temp.style.pixelTop=Math.round((document.body.clientHeight-100)/2)+document.body.scrollTop;
temp.style.pixelLeft=Math.round((document.body.clientWidth-100)/2);
temp.innerHTML=now.getTime();
}
locateCenter();
window.onscroll=locateCenter;
</script>
</body>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货