The open() method

The URL parameter is replaced with the actual URL of the HTML document that is to be opened in the new window.

The name parameter is replaced with the name you give to the new window. The third parameter is used to add attributes to the new window. These attributes are set by using “yes”, “no”, or a numeric value on the right side of the equal sign. There is a comma between each attribute and no space!

window.open("mypage.html" , "MyPage" , "width=400,height=300");

Standard attributes

The table below lists the standard attributes you can use as part of the last parameter in the open() method.

Attribute name

Possible values

Function

width

number

The width of the new window in pixels.

height

number

The height of the new window in pixels.

directories

yes, no, 1, 0

Defines whether or not the new window has directory buttons (for example: What’s New or Link buttons near the top of the browser).

location

yes, no, 1, 0

Defines whether or not the new window has a location box to type in a new URL.

mmenubar

yes, no, 1, 0

Defines whether or not the new window has a menu bar (File, Edit etc).

resizable

yes, no, 1, 0

Defines whether or not the viewer is allowed to resize the new window.

scrollbars

yes, no, 1, 0

Defines whether or not the new window has scroll bars.

status

yes, no, 1, 0

Defines whether or not the new window has a status bar at the bottom.

toolbar

yes, no, 1, 0

Defines whether or not the new window has a toolbar (Back and Forward buttons, Stop button etc).

Note: You can use 1 instead of yes and 0 instead of no.

The following code opens a new window with all the features listed in the table above.