The JavaScript Window open() method is used to open a new browser window or tab. It takes two arguments: the URL of the page to open, and an optional string of window options.
Here are some examples of how the open() method can be used in JavaScript code:
- To open a new window with a specific URL, you can use the following code:
window.open('https://www.example.com');
- To open a new window with a specific size and position, you can use the following code:
window.open('https://www.example.com', '', 'width=800,height=600,left=100,top=100');
- To open a new window in a specific frame or window, you can use the following code:
window.open('https://www.example.com', 'myFrame');
- To open a new window with specific window features, such as a toolbar or scrollbars, you can use the following code:
window.open('https://www.example.com', '', 'toolbar=1,scrollbars=1');
Overall, the open()
method provides a convenient way to open new windows or tabs in a web browser, and allows you to customize the size, position, and features of the new window.
Leave a Reply