大家看一下我的代码!不知道错在哪里???
我写了个让窗口在SCREEN 能自由滚动的程序!
小窗口总是能滚出SCREEN ,我觉得我的程序好想没有错误!!
高手帮帮我!!!
<html>
<head>
<title>New Page 1</title>
<script>
var x=0,y=0,dx=5,dy=5;
var clearId=null;
var interVal=1000;
var win=null;
var w=300,h=200;
win=window.open("","","width=300,height=200");
win.moveBy(0,0);
function startGame()
{
if(x>window.screen.avaliWidth-w|| x<0)
{
dx=-dx;
}
if(y>window.screen.availHeight-h || y<0)
{
dy=-dy;
}
x+=dx;
y+=dy;
win.moveBy(x,y);
clearId=setInterval("startGame()",interVal);
}
function StopGame()
{
clearInterval(clearId);
}
</script>
</head>
<body onLoad="startGame()">
<p align="center"> </p>
<div align="center">
<center>
<table border="1" width="403" height="74">
<tr>
<td width="403" height="74"><input type=button value=" Stop " onClick="StopGame()"></td>
</tr>
</table>
</center>
</div>
</body>
</html>
问题点数:20、回复次数:1Top
1 楼bzscs(沙虫 我爱小美)回复于 2003-12-03 10:52:55 得分 20
<html>
<head>
<title>New Page 1</title>
<script>
var x=0,y=0,dx=50,dy=50;
var clearId=null;
var interVal=1000;
var win=null;
var w=300,h=200;
win=window.open("","","width=300,height=200");
win.moveTo(0,0);
function startGame()
{
if(x>window.screen.availWidth-w || x<0)
{
dx=-dx;
}
if(y>window.screen.availHeight-h || y<0)
{
dy=-dy;
}
x+=dx;
y+=dy;
win.moveTo(x,y);
clearId=setTimeout("startGame()",interVal);
}
function StopGame()
{
clearTimeout(clearId);
}
</script>
</head>
<body onLoad="startGame()">
<p align="center"> </p>
<div align="center">
<center>
<table border="1" width="403" height="74">
<tr>
<td width="403" height="74"><input type=button value=" Stop " onClick="StopGame()"></td>
</tr>
</table>
</center>
</div>
</body>
</html>
Top




