<!-- http://www.knowsky.com -->
<!-- bbs http://bbs.knowsky.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.knowsky.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>