HTML随鼠标滚动的广告图片
--------------------------------------------------------------------------------------------------------------
function init(){
advScroll=document.getElementById("advScroll");
if(advScroll.currentStyle){//IE
advTop=parseInt(advScroll.currentStyle.top);
}else{
advTop=parseInt(document.defaultView.getComputedStyle(advScroll,null).top);//FireFox
}
}
function move(){
advScroll.style.top=(advTop+parseInt(document.documentElement.scrollTop))+"px";
}
window.onload=init;
window.onscroll=move;
--------------------------------------------------------------------------------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
<!--
#advScroll {
position:absolute;
left:13px;
top:128px;
width:109px;
height:122px;
z-index:1;
}
-->
</style>
<script type="text/javascript">
var advTop; //广告层的初始位置
var advScroll;
function init(){
advScroll=document.getElementById("advScroll");
if(advScroll.currentStyle){//IE
advTop=parseInt(advScroll.currentStyle.top);
}else{
advTop=parseInt(document.defaultView.getComputedStyle(advScroll,null).top);//FireFox
}
}
function move(){
advScroll.style.top=(advTop+parseInt(document.documentElement.scrollTop))+"px";
}
window.onload=init;
window.onscroll=move;
</script>
</head>
<body>
<div id="advScroll"><img src="images/adv.jpg" /></div>
<div id="top"><img src="images/main1.JPG"/></div>
<div id="main"><img src="images/main2.JPG"/></div>
<div id="bottom"><img src="images/main3.JPG"/></div>
</body>
</html>