我是 JavaScript 新手,刚开始学习窗口方法。我想写这个方法来让一个新窗口从屏幕的左端移动到右端。但是,代码不起作用。
有人可以告诉我哪里出错了。
<!doctype html>
<html>
<title>Avoid Window</title>
<head>
<script type="text/javascript">
var MovingWindow;
function CreateWindow()
{
MovingWindow = window.open('','MovingWindow','width=100,height=100,menubar=0,toolbar=0,location=0,resizeable=0,status=0');
window.MovingWindow.moveTo(0,0);
while( window.MovingWindow.screenX < window.screen.width - window.MovingWindow.width)
{
window.MovingWindow.moveBy(1,0);
}
}
</script>
</head>
<body>
<h1>Avoid Window</h1>
<p> Click on the button below to create a window which moves from one end of the screen to the other end of the screen</p>
<input type="Button" onClick="CreateWindow();" value="Create Window"/>
<input type="Button" onClick="MoveWindow();" value="Move Window"/>
</body>
</html>