效果: 打开窗口,设定窗口大小 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>