16.12 moveto方法.html

来自「javascript即用即差核心对象手册」· HTML 代码 · 共 24 行

HTML
24
字号
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>moveTo方法演示</title>
</head>
<script>
    var imoved=0;
	intervalID=window.setInterval(moveWindow,100);
	function moveWindow()
	{   
	    var ipx,ipy;
		//随机产生x y坐标
		ipx=Math.round(Math.random()*800);
		ipy=Math.round(Math.random()*800);
		window.moveTo(ipx,ipy);
		imoved++;
		if (imoved>=50)
		    window.clearInterval(intervalID);
	}
</script>
<body>
</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?