Window moveBy() 方法

阅读更多

定义和用法

moveBy() 方法可相对窗口的当前坐标把它移动指定的像素。

语法

window.moveBy(x,y)

 

 

实例

  1. DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="gb2312">
  5. <title>moveBytitle>
  6. <script>
  7. function openWin()
  8. {
  9. myWindow=window.open('','','width=200,height=100');
  10. myWindow.document.write("

    这是我的窗口

    "
    );
  11. }
  12. function moveWin()
  13. {
  14. myWindow.moveBy(250,250);
  15. myWindow.focus();
  16. }
  17. script>
  18. head>
  19. <body>
  20. <input type="button" value="打开我的窗口" onclick="openWin()"/>
  21. <br><br>
  22. <input type="button" value="移动我的窗口" onclick="moveWin()"/>
  23. body>
  24. html>

运行效果

窗口动态向右下移动250

你可能感兴趣的:(Window,moveBy)