Javascript Window Function guide-new window Customization

Source: Internet
Author: User
The basic syntax structure of the window. open () method is as follows:

Window. Open (Surl, sname );

However, you can customize a new window by using two additional parameters:

Window. Open (Surl, sname [, sfeatures] [, breplace]);

By omitting these parameters, you can use the default features. Let's take a look at the breplace parameter, which is only supported by Internet Explorer: 4 and later versions. This parameter is useful only when the first parameter is named as an existing window. It is a Boolean value. If it is true, it indicates that the URL specified by the first parameter replaces the address saved in history by the browsing position of the current window. If it is false, creates a new project in the browsing history of the window (this is the default situation ). This parameter is not very useful because it is only supported by Microsoft browsers. Next let's take a look at the widely known JavaScript window setting nature.

The 3rd parameters of the open () method are a string that contains a list of options separated by commas ). Before entering the ocean of available functions, let's take a look at their meanings. Here is an example:

Win = Window. Open ("http://www.docjs.com/", "docjs", "location = 1, menubar = 1, resizable = 1 ");

This statement opens a variable-size window with an address bar and a menu bar, and other features are disabled. For example, if the status feature is not specified, the status bar is absent in the new window. Note that there are several other methods to define window features. The following are some commands that are equivalent to the functions of the preceding statements:

Win = Window. Open ("http://www.docjs.com/", "docjs", "location, menubar, resizable ");

Win = Window. Open ("http://www.docjs.com/", "docjs", "location = Yes, menubar = Yes, resizable = yes ");

Win = Window. Open ("http://www.docjs.com/", "docjs", "location, menubar = 1, resizable = yes ");

Many features can be yes or no. For these features, you can also use 1 to replace Yes, 0 to replace no. If you want to activate a feature, you can also simply list the feature names in the sfeatures string. If not listed, this function is blocked (except titlebar and hotkeys ). The sfeatures parameter is a comma-separated function list, which should not contain any space or blank characters. Each element in the list should contain the following format:

Feature [= value]

There is a big difference between allocating an empty string of the sfeatures parameter and omitting it all. If open () is called without any parameters, all features are set to the default value. In other words, the browser creates a window with default width and height, standard menus, toolbar, and other features of the browser. If you use an empty string as the list of functions required, the browser opens a window where all its features are blocked (except titlebar and hotkeys ).

The 2nd parameter sname of the window. open () method specifies the window name. If it is an existing window name, the browser loads the specified URL (Surl) in that window ). Therefore, if the sname specifies an existing window, the browser ignores the defined feature list.

Not all window features are supported by all browsers. If the browser cannot recognize the specified feature, it simply ignores it. Let's take a look at the definitions of various window features in javascript:

Alwayslowered Innerwidth Screeny
Alwaysraised Left Scrollbars
Channelmode Location Status
Dependent Menubar Titlebar
Directories Outerwidth Toolbar
Fullscreen Outerheight Top
Height Menubar Width
Hotkeys Resizable Z-Lock
Innerheight Screenx  

Alwayslowered
Internet Explorer: not supported

Navigator: Version 4 +

The specified window is always kept at the bottom of the stack. In other words, no matter whether the new window is activated or not, it is always under another window.

Window. Open ("alwayslowered.html", "_ blank", "alwayslowered ");

Alwaysraised
Internet Explorer: not supported

Navigator: Version 4 +

The specified window is always kept at the top of the stack. In other words, no matter whether the new window is activated or not, it is always on another window.

Window. Open ("alwaysraised.html", "_ blank", "alwaysraised ");

Channelmode
Internet Explorer: Version 4 +

Navigator: not supported

Specify whether to display the window in theater mode and whether to display the channel area.

Window. Open ("channelmode.html", "_ blank", "channelmode ");

Dependent
Internet Explorer: not supported

Navigator: Version 4 +

Define whether the window is the dependent child window currently opened. The dependency window is also closed when its parent window is closed. On Windows, a dependency window is not displayed on the taskbar.

Window. Open ("dependent.html", "_ blank", "dependent ");

Directories
Internet Explorer: All Versions

Navigator: All Versions

Specify whether to display the directory button (such as the "What's cool" and "What's New" button ). Internet Explorer references these directory buttons as the link toolbar, and Navigator (Version 4 and later) is called the personal toolbar.

Window. Open ("directories.html", "_ blank", "directories ");

Fullscreen
Internet Explorer: Version 4 +

Navigator: not supported

Determines whether to open the browser in full screen mode. Be careful when using full screen mode, because in this mode, the title bar and menu of the browser are hidden, and you should provide a button or other visual clues to help you close the window. Of course, Windows can also be closed using the hot key Alt + F4.

Window. Open ("fullscreen.html", "_ blank", "fullscreen ");

Height
Internet Explorer: All Versions

Navigator: All Versions

The height of the area displayed in the window document is defined in pixels. The minimum value is 100. If only the height is defined, Internet Explorer uses the given height and default width. If neither width nor innerwidth is specified for navigator, this attribute is ignored.

Window. Open ("height.html", "_ blank", "Height = 200, width = 300 ");

Hotkeys
Internet Explorer: not supported

Navigator: Version 4 +

If it is not defined (or 0), most hot keys of new windows without Menu Bars are blocked. However, the security and exit hotkeys are retained.

Window. Open ("hotkeys.html", "_ blank", "hotkeys = 0, menubar = 0 ");

Innerheight
Internet Explorer: not supported

Navigator: Version 4 +

The height of the area displayed in the window document is defined in pixels. The minimum value is 100. In Navigator version 4, this feature replaces height to maintain backward compatibility. If neither width nor innerwidth is specified for navigator, this attribute is ignored.

Window. Open ("innerheight.html", "_ blank", "innerheight = 200, innerwidth = 300 ");

Innerwidth
Internet Explorer: not supported

Navigator: Version 4 +

Defines the width of the display area of the window document in pixels. The minimum value is 100. In Navigator version 4, this feature replaces width to maintain backward compatibility. If the navigator does not specify the height or innerheight at the same time, this attribute is ignored.

Window. Open ("innerwidth.html", "_ blank", "innerheight = 200, innerwidth = 300 ");

Left
Internet Explorer: Version 4 +

Navigator: not supported

Defines the left X mark of the window in pixels.

Window. Open ("left.html", "_ blank", "Left = 20 ");

Location
Internet Explorer: All Versions

Navigator: All Versions

Defines whether to display the text fields in the browser for URL input.

Window. Open ("location.html", "_ blank", "location ");

Menubar
Internet Explorer: All Versions

Navigator: All Versions

Define whether to display the menu bar (the menu bar is located at the top of the window, including "file" and "edit ).

Window. Open ("menubar.html", "_ blank", "menubar ");

Outerheight
Internet Explorer: not supported

Navigator: Version 4 +

Defines the total height of a window (its external border) in pixels. The minimum value is more than 100, because the height of the window content area must be at least 100. If outerwidth is not defined at the same time, navigator ignores this feature.

Window. Open ("outerheight.html", "_ blank", "outerheight = 200, outerwidth = 300 ");

Outerwidth
Internet Explorer: not supported

Navigator: Version 4 +

Defines the total width of a window (its external border) in pixels. The minimum value is more than 100, because the width of the window content area must be at least 100. If outerheight is not defined at the same time, navigator ignores this feature.

Window. Open ("outerwidth.html", "_ blank", "outerheight = 200, outerwidth = 300 ");

Resizable
Internet Explorer: All Versions

Navigator: All Versions

Defines whether a window can be scaled by its boundary. Depending on the platform, users may have other methods to change the window size.

Window. Open ("resizable.html", "_ blank", "resizable ");

Screenx
Internet Explorer: not supported

Navigator: Version 4 +

Defines the X coordinates of the window in pixels.

Window. Open ("screenx.html", "_ blank", "screenx = 20 ");

Screeny
Internet Explorer: not supported

Navigator: Version 4 +

Defines the Y coordinate of the window in pixels.

Window. Open ("screeny.html", "_ blank", "screeny = 20 ");

Scrollbars
Internet Explorer: All Versions

Navigator: All Versions

Define whether to activate the horizontal and vertical scroll bars.

Window. Open ("scrollbars.html", "_ blank", "scrollbars ");

Status
Internet Explorer: All Versions

Navigator: All Versions

Determines whether to add a status bar in the lower part of the window.

Window. Open ("status.html", "_ blank", "status ");

Titlebar
Internet Explorer: Version 5 +

Navigator: Version 4 +

Defines whether to display the title bar of the window. In Internet Explorer, this feature is blocked unless the caller is an HTML application or a trusted dialog box.

Window. Open ("titlebar.html", "_ blank", "titlebar = 0 ");

Toolbar
Internet Explorer: All Versions

Navigator: All Versions

Defines whether to display the toolbar of the browser (in the upper part of the window, including "backward" and "Forward ").

Window. Open ("toolbar.html", "_ blank", "toolbar ");

Top
Internet Explorer: Version 4 +

Navigator: not supported

Defines the ordinate of a window in pixels.

Window. Open ("top.html", "_ blank", "Top = 20 ");

Width
Internet Explorer: All Versions

Navigator: All Versions

Defines the width of the display area of the window document in pixels. The minimum value is 100. If only the width is defined, Internet Explorer uses the given width and default height. If the navigator does not specify the height or innerheight at the same time, this attribute is ignored.

Window. Open ("width.html", "_ blank", "Height = 200, width = 300 ");

Z-Lock
Internet Explorer: not supported

Navigator: Version 4 +

When defining window activation, it does not float in the stack. That is to say, when a new window is activated, it cannot be located above other windows.

Window. Open ("zlock.html", "_ blank", "Z-lock ");
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.