The window.open() method takes four optional arguments which are URL of the window, Window name, attributes of 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”);
The first argument of window.open() method allows to display 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 which 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 is given 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 same as written false.
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 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 button, you can use the following code.
<input type=button name="open" value="Open window" onclick="window.open('http://www.siteforinfotech.com/p/about-us.html ','new window', 'width=400, height=350, status=yes, resizable=yes');">
To open a new pop up window on <a> href link, you can use the following code.
var w=window.open(); w.alert("You are going to visit:http://www.siteforinfotech.com"); w.location="http://www.siteforinfotech.com";