JavaScript: Open a New Browser Window
The JavaScript window object contains the open method. This can be used to open new browser windows via JavaScript, as follows:
window.open('url','windowname','options');
url is the path to the file to be opened in the new window
windowname is a variable reference to the opened window
options are the specifications of the opened window. The available options are:
- height: The height of the window, in pixels
- width: The width of the window, in pixels
- top: The Y coordinate of the window, measured in pixels from the top of the screen
- left: The X coordinate of the window, measured in pixels from the left of the screen
- scrollbars: Whether to show horizontal and vertical scrollbars, if the page overflows
- toolbar: Whether to show the browser toolbar
- status: Whether to show the browser status line
- menubar: Whether to show the browser menu bar
- location: Whether to show the URL input field in the browser window
- resizable: Whether the window can be resized
Example:
window.open('myFile.html','myWindow','top:40,left:100,menubar=no,toolbar=yes');
Note that options are separated by commas. If no options are specified, then all options are present and the windows is placed in the upper left corner of the screen.