javaScript 不会随滚动条滚动的层

 


<html>
<head>
<title></title>
<script language="javascript">
 var size1=0;
 var size2=0;
 function shu1(){
 size1=document.getElementById("Layer1").style.pixelTop;
 size2=document.getElementById("Layer2").style.pixelTop;
 //alert(size1);
 }
 function shu2(){
 document.getElementById("Layer1").style.pixelTop=size1+document.body.scrollTop;
 document.getElementById("Layer2").style.pixelTop=size2+document.body.scrollTop;
 }
 window.onscroll=shu2;
 
 function guanbiyu(){
 
 document.getElementById("Layer1").style.display="none";
 document.getElementById("Layer2").style.display="none";
 
 
 }

</script>


</head>
<body onLoad="shu1()">
<div id="Layer1" style="position:absolute;
 left:160px;
 top:49px;
 width:81px;
 height:116px;
 z-index:1;"><img src="image/close.jpg" width="109" height="123"></div>
<div id="Layer2" style="position:absolute;
 left:238px;
 top:51px;
 width:25px;
 height:32px;
 z-index:2;" onClick="guanbiyu()">关闭</div>
<table width="200" border="1">
  <tr>
    <td><p><img src="image/DLC-2.JPG" width="556" height="427"></p>
    <p><img src="image/DLC-3.JPG" width="556" height="560"></p></td>
  </tr>
</table>
</body>
</html>

你可能感兴趣的:(javaScript 不会随滚动条滚动的层)