日期:2014-05-16 浏览次数:20362 次
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<style>
div{width:30px;height:30px;background-color:#06F;position:absolute;top:0;left:0;}
</style>
<script>
function getClint(ev)
{
var scrollTop=document.documentElement.scrollTop||document.body.scrollTop;
var scrollLeft=document.documentElement.scrollLeft||document.body.scrollLeft;
return {x:ev.clientX+scrollLeft,y:ev.clientY+scrollTop}
}
document.onmousemove=function(ev)
{
var aDiv=document.getElementsByTagName("div");
var oEvent=ev||event;
var Clint=getClint(oEvent);
for(var i=aDiv.length-1;i>0;i--)
{
aDiv[i].style.left=aDiv[i-1].offsetLeft+"px";
aDiv[i].style.top=aDiv[i-1].offsetTop+"px";
}
aDiv[0].style.left=Clint.x+"px";
aDiv[0].style.top=Clint.y+"px";
}
</script>
</head>
<body>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</body>
</html>