js 메서드: 코드 복사 코드는 다음과 같습니다. New Document <br> window.onload=function(){<br> //写入<br> var oneInner = document.createElement("div");<br> oneInner.setAttribute("style","background:#663398;position:absolute;width:100px;height:100px;border:solid 3px #2F74A7;cursor:pointer;");<br> var oneButton = document.createElement("input");<br> oneButton.setAttribute("type","button");<br> oneButton.setAttribute("value","x");<br> if (oneButton.style.cssFloat)<br> {<br> oneButton.style.cssFloat="right"<br> }<br> else<br> {oneButton.style.styleFloat="right"}<br> oneInner.appendChild(oneButton);<br> document.body.appendChild(oneInner);<br><br> //定时器<br> var a1a = setInterval(moves,100);<br> //函数 <p> var x = 10;<br> var y = 10;</p> <p> function moves(){<br> var tops = oneInner.offsetTop<br> var lefts = oneInner.offsetLeft</p> <p> if (lefts>=document.documentElement.clientWidth-oneInner.offsetWidth||lefts<=0)<BR> {<BR> x=-x<BR> }</P><P> if (tops>=document.documentElement.clientHeight-oneInner.offsetHeight||tops<=0)<BR> {<BR> y =-y<BR> }<br><br> 탑 =y;<BR> 왼쪽 =x;</P> <P> oneInner.style.tops "px"<BR> oneInner.style.left=lefts "px"<BR> }</P> <P> //悬停停止<BR> oneInner.onmouseover=function(){<BR> clearInterval(a1a);<BR> }<BR> //放手继续运动<BR> oneInner.onmouseout=function(){ <BR> a1a =setInterval(moves,100);<BR> }<BR> //删除<BR> oneButton.onclick=function() {<BR> document.body.removeChild(oneInner);<BR> }<BR> }<BR> <본문>