The window.open() method takes four optional arguments which are URL of the window, Window name, attributes of the window, the boolean value to replace or not the current window.
Syntax: window.open("windowname.html", "New Window", "width=width in pixel, height=height in pixel, status=yes or no, resizable=yes or no");
Arguments of the window.open() method
The first argument of window.open() method allows displaying a given URL in the new window. If the argument is omitted, the special blank-page URL:about: blank is used.
The second argument of window.open() method is a string that specifies a window name. If the argument is omitted, the special name “_blank” is used which opens a new, unnamed window.
The third optional argument of window.open() method is a comma-separated list of size and features attributes for the new window to be opened. If you omit this argument, the new window will appear with a default size and has a full set of UI components: a menu bar, status bar, toolbar, etc.
The fourth optional argument of window.open() is useful only when the second argument names an existing window. It is a boolean value that indicates whether the URL specified as the first argument should replace the current entry in the window’s browsing history: written true, or create a new entry in the window’s browsing history: written false. And omitting the argument is the same as written false.
Examples of using window.open() method
Here is an example to open a small but resizable browser window with a status bar but no menu bar, tool-bar, or location bar.
window.open("new_window.html", "New Window", "width=400, height=350, status=yes, resizable=yes");
Here status bar is showing using status=yes and the window is resizable using resizable=yes, if you don’t want to show the status bar, you can use status=no and want the fixed window, can use resizable=no in the argument.
To open a new pop up window on onclick event of the button, you can use the following code.
<input type=button name="open" value="Open window" onclick="window.open('https://www.siteforinfotech.com/p/about-us.html ','new window', 'width=400, height=350, status=yes, resizable=yes');">
A popup window will open when you click on the button below.
To open a new pop up window on a hyperlink, you can use the following code.
When you click on the following link, it will open a popup window.Open Pop Up window
var w=window.open(); w.alert("You are going to visit:https://www.siteforinfotech.com"); w.location="https://www.siteforinfotech.com";