<div id="img" onmouseover="clearInterval(interval)" onmouseout="interval = setInterval('changePos()', delay)" align="middle"> <a href="#" ></a><br><span class="reset" onclick="clearInterval(interval);img.style.visibility = 'hidden'">关闭 X</span> </div> <script type="text/javascript"> var xPos=300; var yPos=200; var step=1; var delay=16; var height=0; var Hoffset=0; var Woffset=0; var yon=0; var xon=0; var pause=false; var interval; changePos("img") ; function changePos(objName) { var thediv=document.getElementById(objName); thediv.style.position="absolute"; thediv.style.left=parseInt(window.screen.availWidth*Math.random()) + "px"; thediv.style.top=parseInt(window.screen.availHeight*Math.random()) + "px"; thediv.setAttribute("xDir",1); thediv.setAttribute("yDir",1); window.setInterval("randPosition(" + objName + ")","18","JavaScript"); } function randPosition(obj) { var x=parseInt(obj.style.left); if(x>=1500) obj.setAttribute("xDir",-1); if(x<=0) obj.setAttribute("xDir",1); x+=parseInt(obj.getAttribute("xDir")); var y=parseInt(obj.style.top); if(y>=700) obj.setAttribute("yDir",-1); if(y<=0) obj.setAttribute("yDir",1); y+=parseInt(obj.getAttribute("yDir")); obj.style.left=x +"px"; obj.style.top =y +"px"; } function start() { img.style.visibility = "visible"; interval = setInterval('changePos()', delay); } start(); </script >
LEATH
相关分类