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>
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。