<div class="htmlarea"> <textarea id="runcode70071"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <style type="text/css"> #body{text-align:center;} #test{width:119px;position:absolute;margin:10px auto;height:114px;background:url(/images/logo.gif) ;border:2px dotted red;} </style> <div style="margin:10px 200px"> <div> <input type="button" value="~~~让我抖抖吧~~" onclick="nn.start()"> </div> <div> <input type="button" value="别抖了眼睛晕的很" onclick="nn.stop()"> </div> <div id="test"> </div> </div> </textarea> <br> <input onclick="runEx('runcode70071')" type="button" value="运行代码"><input onclick="doCopy('runcode70071')" type="button" value="复制代码"><input onclick="doSave(runcode70071)" type="button" value="保存代码"> <a href="http://www.jb51.net/article/23421.htm" title="查看具体详情" target="_blank"> </a>[Ctrl A 모두 선택 참고: </div>외부 J를 도입해야 하는 경우 실행하려면 새로 고쳐야 합니다 <script type="text/javascript"></script>]<script type="text/javascript"> var m=document.getElementById("test"); function SKclass (obj,Rate,speed) { var oL=obj.offsetLeft; var oT=obj.offsetTop; this.stop=null; this.oTime=null; this.state=0; var om=this; this.start=function(){ if(this.state==0){ ostart(); this.state=1; } else{alert("这样你受得了吗?")} } var ostart=function(){ if(parseInt(obj.style.left)==oL-2){ obj.style.top=oT+2+"px"; setTimeout(function(){obj.style.left=oL+2+"px"},Rate) } else{ obj.style.top=oT-2+"px"; setTimeout(function(){obj.style.left=oL-2+"px"},Rate) } om.oTime=setTimeout(function(){ostart()},speed); } this.stop=function(){ clearTimeout(om.oTime); this.state=0; } } var nn=new SKclass(m,20,50); </script>