window.open () Specific explanations and browser compatibility issues

Source: Internet
Author: User

First, the basic syntax:
window.open (Pageurl,name,parameters)
Of
Pageurl to Subform path
Name is the child form name
Parameters for form parameters (separated by commas)

Second, demonstration sample

<script type= "Text/javascript" >window.open (' page.html ', ' newwindow ', ' height=500,width=800,top=0,left=0,     Toolbar=no,menubar=no,scrollbars=no, Resizable=no,location=no, Status=no ') </script>
page.html will open in the new form NewWindow, with a width of 800, a height of 500, 0 pixels from the top of the screen, 0 pixels on the left,

No toolbar, no menu bar, no scroll bar, no resizing, no address bar, no status bar.

Differences in support for form feature sfeatures parameters for window.open () in each browser

Summary of results of each browser execution:

The above table shows the degree of support for each browser for each of the features options, which requires special instructions such as the following:

"Callout 1": IE7 IE8 Firefox Chrome Safari, when the "menubar" option is "Yes", the menu bar is not displayed by default, you need to press the ALT key to display the menu bar, whereas when the "menubar" option is "no", The menu bar does not appear even if you press the ALT key.
Callout 2: In Safari, opening the location option is the same as when the toolbar option is turned on.
"Callout 3": IE6 IE8 Chrome, using "Top" and "left" positioning, assuming that the set of coordinates values are too large, the pop-up form may appear outside the screen's viewable range.
"Callout 4": IE7 Firefox Safari Opera, using "Top" and "left" positioning, assuming that the set of coordinates are too large, the window realizes that it is actively adjusting the "top" and "left" values to ensure that the form is displayed in the visible area of the screen.
"Callout 5": In Chrome Opera, "left" and "top" are not supported without setting the "width" and "height" values, and the "left" and "top" setting values do not take effect.
"Callout 6": Chrome does not support the use of "width" and "height" without setting the "left" and "height" values, at which time the "width" Height setting value does not take effect. In combination with the "callout 5" description, the popup form in chrome must assign all of them regardless of whether you want to set a width or a value in the position, otherwise it will not work.
"Callout 7": In Firefox Chrome, the address bar is always displayed.
"Callout 8": In Opera, the address bar is not displayed by default, but you can click on the top bar of the page to make him display, set "Location=yes" after the address bar will be displayed on its own initiative.
"Callout 9": In Chrome Opera, no matter how the "menubar" value is set, the menu bar is never displayed.
"Callout 10": Firefox Safari Chrome Opera no matter how the "resizable" value is set, the form can always be resized by the user.
"Callout 11": In Safari Chrome, the scroll bar is always visible, regardless of how the "scrollbars" value is set, in the presence of a scroll bar on the page.
"Callout 12": IE7 can support "status" to hide the status bar by default in Windows XP SP3 system, while "status" parameter is not supported in Windows Vista system default environment, the status bar is always visible. This is associated with the default IE7 in both systems The minor version is different, the former version is lower, the latter version is higher.
"Callout 13": In Firefox, the status bar is always visible, regardless of the "status" value, while in Chrome Opera, the status bar is always invisible.
"Callout 14": In Chrome Opera, toolbars are never displayed, regardless of how the "toolbar" value is set.
To sum up, it can be seen that the window.open method of Sfeatures The extent of support there is a huge difference, use should be cautious.

excerpt from:/ c3>http://www.w3help.org/zh-cn/causes/BX1053#


in general, we need to open the page with window.open Center display, demo sample code :

var width=800;  The width of the popup form; var height=500; The height of the popup form; var top = (window.screen.availheight-height)/2; The vertical position of the form; var left = (window.screen.availwidth-width)/2;  The horizontal position of the form; window.open (' page.html ', ' newwindow ', ' height= ' +height+ ', width= ' +width+ ', top= ' +top+ ', left= ' +left+ ',     Toolbar=no,menubar=no,scrollbars=no, Resizable=no,location=no, Status=no ')

the difference between availheight and height

Window.screen.width returns the current screen width (resolution value) Window.screen.height returns the current screen height (resolution value) Screen.availwidth, Screen.availheight refers to the removal of the length of the taskbar (taskbar)

Welcome to add Java Technology Exchange Group: 74955800

window.open () Specific explanations and browser compatibility issues

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.