Return the x and y coordinates of the new window relative to the screen:
<!DOCTYPE html> <html> <head> <script> function myFunction() {// w ww . j av a 2 s. c o m var myWindow = window.open("", "myWin"); myWindow.document.write("<p>This is 'myWin'"); myWindow.document.write("<br>ScreenLeft: " + myWindow.screenLeft); myWindow.document.write("<br>ScreenTop: " + myWindow.screenTop + "</p>"); } </script> </head> <body> <button onclick="myFunction()">Open "myWin"</button> </body> </html>
The screenLeft and screenTop properties returns the x (horizontal) and y (vertical) coordinates of the window relative to the screen.
The screenLeft and screenTop properties returns a Number representing the horizontal and vertical distance of the window relative to the screen, in pixels.