divレイヤは常にページの真ん中にあります
6888 ワード
<html>
<head>
<title> </title>
</head>
<body>
fdfdfadf
<table width="200" height="3600" border="1">
<tr>
<td>qqxcxcxzc .dfd...,dsfsd,dfds</td>
</tr>
</table>
<div id="a" style="POSITION: absolute;border:1px solid red;">11dsfsdf23</div>
<script>
function $(id){
return document.getElementById(id);
}
function getPageTopScroll(){
var yScroll;
if (self.pageYOffset) {
yScroll = self.pageYOffset;
} else if (document.documentElement && document.documentElement.scrollTop){
yScroll = document.documentElement.scrollTop;
} else if (document.body) {
yScroll = document.body.scrollTop;
}
return yScroll;
}
window.onload=function div(){
var aa=getPageTopScroll();
$("a").style.top=aa+document.body.clientHeight/2;
setTimeout("div()",100)
}
</script>
</body>
</html>