moveBy()
Window moveBy() 方法
定义和用法
moveBy() 方法可相对窗口的当前坐标把它移动指定的像素。
语法
window.moveBy(x,y)
浏览器支持
所有主要浏览器都支持 moveBy() 方法
实例
把窗口相对其当前位置移动250个像素:
<html>
<head>
<script>
function openWin()
{
myWindow=window.open(‘‘,‘‘,‘width=200,height=100‘);
myWindow.document.write("<p>This is ‘myWindow‘</p>");
}
function moveWin()
{
myWindow.moveBy(250,250);
myWindow.focus();
}
</script>
</head>
<body>
<input type="button" value="Open ‘myWindow‘" onclick="openWin()">
<br><br>
<input type="button" value="Move ‘myWindow‘" onclick="moveWin()">
</body>
</html>
<head>
<script>
function openWin()
{
myWindow=window.open(‘‘,‘‘,‘width=200,height=100‘);
myWindow.document.write("<p>This is ‘myWindow‘</p>");
}
function moveWin()
{
myWindow.moveBy(250,250);
myWindow.focus();
}
</script>
</head>
<body>
<input type="button" value="Open ‘myWindow‘" onclick="openWin()">
<br><br>
<input type="button" value="Move ‘myWindow‘" onclick="moveWin()">
</body>
</html>