The window.open()
method in JavaScript is used to open a new browser window or tab. It can be used to open a URL, a file on your local system, or a data stream.
Here’s the basic syntax of the window.open()
method:
window.open(URL, name, specs, replace)
URL
: The URL of the page you want to open. This can be a web page, a file on your local system, or a data stream.name
: The name of the window. This can be used to target the window with JavaScript.specs
: A string of comma-separated values that specify the size and features of the window. For example, you can specify the width, height, scrollbars, and more.replace
: A boolean value that specifies whether the current page should be replaced with the new window. Ifreplace
is set totrue
, the current page will be replaced with the new window. Ifreplace
is set tofalse
, the new window will be opened in a new tab or window.
Here’s an example of how to use the window.open()
method to open a URL in a new window:
window.open("https://www.example.com", "exampleWindow", "width=400, height=400");
In this example, a new window will be opened to the URL https://www.example.com
with a width of 400 pixels and a height of 400 pixels. The window will be named “exampleWindow”, which can be used to target the window with JavaScript.
+ There are no comments
Add yours