HTML | Window moveTo() Method
The moveTo() method is used in the window to moves the window from the left and top coordinates.
Syntax:
window.moveTo(x, y)
Parameter:
- x: A positive or negative number that specifies the horizontal coordinate to be moved to
- y: A positive or negative number specifies the vertical coordinate to be moved to
Example: Move the window.
<!DOCTYPE html> <html> <head> <title> Window moveTo() Method </title> <style> h1 { color: green; } </style> </head> <body> <center> <h1>Geeks for Geeks</h1> <button onclick="openWin()"> Create </button> <button onclick="moveWin()"> Move </button> <script> var myWindow; function openWin() { myWindow = window.open("", "myWindow", "width=200", "height=100"); myWindow.document.write( "<p>This is 'myWindow'</p>"); } function moveWin() { myWindow.moveTo(500, 100); myWindow.focus(); } </script> </center> </body> </html> |
chevron_right
filter_none
Output:
Initial:

New window:

Move window:

Supported Browsers: The browser supported by Window moveTo() Method are listed below:
- Goole Chrome
- Mozilla Firefox
- Opera
- Safari
- Edge
Recommended Posts:
- HTML | canvas moveTo() Method
- HTML | Window alert( ) Method
- HTML | Window atob( ) Method
- HTML | Window resizeBy() Method
- HTML | DOM Window btoa() Method
- HTML | DOM Window stop() Method
- HTML | Window resizeTo() Method
- HTML | Window createPopup() Method
- HTML | Window scrollBy() method
- HTML | Window moveBy() Method
- Javascript | Window Blur() and Window Focus() Method
- HTML | Window top( ) Property
- HTML | Window self( ) Property
- HTML | Window name Property
- HTML | Window screenY Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



