中文(繁体)
<!-- http://www.downcodes.com --> <!-- bbs http://bbs.downcodes.com --> <!--要完成此效果需要兩個步驟第一步:把如下程式碼加入<head>區域中--> <script type="text/javascript"> var x=0,y=0,w=200,h=100, dx=5,dy=5, interval=100 var win=null; var intervalID; function startIt() { win=window.open('javascript:"http://www.downcodes.com"',"","width="+w+",height="+ h) win.moveTo(x,y) intervalID = window.setInterval("bounce()",interval) } var running=false; var close=false; function bounce() { running=true if (win.closed) { clearInterval(intervalID) running=false return } if ((x+dx>(500-w)) || (x+dx<0))dx=-dx if ((y+dy>(500-h)) | | (y+dy<0))dx=-dy x+=dx y+=dy win.moveTo(x,y) if (close) { win.close() clearInterval(intervalID) } } function closeWin() { if ( running) close=true } </script> <!--第二步:把如下程式碼加入<body>區域--> <p><a href="#" onMousedown='startIt()'>顯示視窗</a></p> <p> <a href="#" onMousedown='closeWin()'>關閉視窗</a></p>