窗口在屏幕上来回走动

效果: 打开窗口,设定窗口大小 200x200, 窗口在屏幕中来回动 (只看IE效果)

	<!DOCTYPE html>
	<html lang="en">
	<head>
		<meta charset="UTF-8">
		<title>Document</title>
	</head>
	<body>
		<div>
			<button onclick="openFn()">新窗口</button>
			<button onclick="moveTo()">开启吧</button>
			<button onclick="moveBy()">启动</button>
		</div>
	

	<script>
		var newWindow=null;
		function openFn(){
			newWindow=window.open('','','width=200,height=200');
		}
		function moveTo(){
			newWindow.moveTo(Math.random()*900,Math.random()*900);
			newWindow.focus();
			setTimeout(moveTo,500);
		}
		
	</script>
</body>
</html>
posted @ 2017-08-30 20:18  不完美的完美  阅读(250)  评论(0编辑  收藏  举报