<script type="text/ecmascript">
function top(){
  var advInitTop=document.getElementById("advlayer").style.pixeltop=document.body.scrollTop;//广告层元素距上边界的位置

    function drag(){             //使广告图片所在层随滚动条同步移动
     document.getElementById("advlayer").style.pixeltop=advInitTop+document.body.scrollTop;
}
    window.onscroll=drag;  //滚动条事件
    </script>
<body onLoad="top()">
<div id="advlayer" style="position:absolute;left:30px;top:90px;width:200px;height:70px;z-index:2;" ><img src="image/b.gif" width="300" height="170"></div>
    <div id="closes" style="position:absolute;left:290px;top:90px;width:30px;height:20px;z-index:2;"><img src="image/a.gif" width="30" height="20"></div>
</body>
</html>