Window moveTo() 方法

定義和用法
moveTo() 方法可把窗口的左上角移動(dòng)到一個(gè)指定的坐標(biāo)。
語法
window.moveTo(x,y)
瀏覽器支持
所有主要瀏覽器都支持 moveTo() 方法
注意: 指定moveTo(0.0),在Opera在瀏覽器的左上角。
實(shí)例
實(shí)例
新窗口移動(dòng)到屏幕上方左上角:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>W3Cschool教程(w3cschool.cn)</title>
<script>
function openWin(){
myWindow=window.open('','','width=200,height=100');
myWindow.document.write("<p>這是我的窗口</p>");
}
function moveWin(){
myWindow.moveTo(0,0);
myWindow.focus();
}
</script>
</head>
<body>
<input type="button" value="打開窗口" onclick="openWin()" />
<br><br>
<input type="button" value="移動(dòng)窗口" onclick="moveWin()" />
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>W3Cschool教程(w3cschool.cn)</title>
<script>
function openWin(){
myWindow=window.open('','','width=200,height=100');
myWindow.document.write("<p>這是我的窗口</p>");
}
function moveWin(){
myWindow.moveTo(0,0);
myWindow.focus();
}
</script>
</head>
<body>
<input type="button" value="打開窗口" onclick="openWin()" />
<br><br>
<input type="button" value="移動(dòng)窗口" onclick="moveWin()" />
</body>
</html>
嘗試一下 ?

更多建議: