让DIV动起来
<html> <head> <meta charset="utf-8"> <title>无标题文档</title> <style type="text/css"> *{margin:0;padding:0;} #div1{width:100px;height:100px;background:red;position:absolute;left:1000px;top:30px;} </style> <script type="text/javascript"> var tmrie=null; window.onload=function() { var oDiv=document.getElementById('div1'); tmrie=setInterval(function() { var left=(300-oDiv.offsetLeft)/10; var ipar=left>0?Math.ceil(left):Math.floor(left); if(oDiv.offsetLeft==300) { clearInterval(tmrie); } else { oDiv.style.left=oDiv.offsetLeft+ipar+'px'; } },30); }; </script> </head> <body> <div id="div1"> </div> <div style="height:200px;width:1px;background:#000;position:absolute;left:400px;"></div> </body> </html>