哪位大哥帮个忙,随着鼠标滚动的广告图片。在线等待
<body>
<script type="text/javascript">
var divobj; //层对象
var divTop; //层距页面顶端距离
var divleft; //层距页面的左距离
var tagName = document.getElementsByTagName("li");
function place() {
var divobj = document.getElementById("adver") //获得层关系
if (divobj.currentStyle) { //IE浏览器
divTop = parseInt(divobj.currentStyle.top); //来获取层距离页面顶端的位置
divleft = parseInt(divobj.currentStyle.left); //来获取层距离页面左端的位置
alert("上" + divTop + "左" + divleft);
}
else { //firefox浏览器
divTop = parseInt(document.defaultView.getComputedStyle(divobj, null).top);
divleft = parseInt(document.defaultView.getComputedStyle(divobj, null).left);
}
}
function move() {
divobj.style.top = divTop + parseInt(document.documentElement.scrollTop) + "px";
divobj.style.left = divleft + parseInt(document.documentElement.scrollLeft) + "px";
}
window.onload = place;
window.onscroll = move;
</script>
<div id="adver"><img src="images/gg=0.jpg" /></div>
<div><img src="images/5.jpg"/></div>
</body>
------解决方案--------------------
注意头部W3c引用
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">