Standard reference
No.
Problem description
You can use the Window.Open method to pop up a new window, where the open method's sfeatures parameter options are different in each browser, which could cause the same code to make a huge difference in the way the browser pops up the window.
The impact
Causes differences in the location and size of the windows that are open in different browsers, and whether there is an address bar, a menu bar, a status bar, a scroll bar, or a full-screen representation.
The affected browser
Problem analysis
The Open method belongs to the Window object, which is used to open a new browser window, where the Window object is also part of the BOM (Browser object Model) category. Unfortunately, the BOM has not been standardized, it is developed by various browser vendors, so there will be real differences.
To this day, the HTML5 standard draft has begun to standardize the Bom,window object is also in the draft, the draft of the open method of the shape parameters are window.open([ url [,target[,features[,replace]]]])
briefly enumerated and introduced. But when it comes to features, only "This parameter function description is ignored", the specific parameters function is unknown.
In the official developer site of the browser vendors that can be found, only Mozilla MDC and Micorsoft MSDN have written instructions for the Open method features parameters. Among them, the MDC introduces very concise, only describes the parameter format, and MSDN in the detailed parameter format and optional key-value pair description, for the option value and the default value of the option this article will not be listed, readers can see the following MSDN documentation description.
For a detailed description of the window.open method in Firefox, see MDC:window.open
For a detailed description of the window.open methods in IE, see Msdn:open method
This article uses the features parameter options listed in MSDN as the benchmark criteria and constructs the following test code:
<script>function openw3c (sfeatures) {window.open ("http://www.w3.org/", "", Sfeatures,false);} </script>Because each browser has a different auto-processing mechanism for pop-ups, in order to not affect the accuracy of the test, the pop-up window can be opened before running the test code because all browsing is set to open.
Summary of running results for each browser:
|
IE6 |
IE7 |
IE8 |
Firefox |
Safari |
Chrome |
Opera |
Channelmode |
Not supported |
Not supported |
Not supported |
Not supported |
Not supported |
Not supported |
Not supported |
Directories |
Not supported |
Not supported |
Not supported |
Not supported |
Not supported |
Not supported |
Not supported |
Fullscreen |
Support |
Support |
Support |
Not supported |
Not supported |
Not supported |
Not supported |
Location |
Support |
Support |
Support |
Not supported 7 |
Support 2 |
Not supported 7 |
Support 8 |
MenuBar |
Support |
Support 1 |
Support 1 |
Support 1 |
Support 1 |
Not supported 9 |
Not supported 9 |
Resizable |
Support |
Support |
Support |
Not supported 10 |
Not supported 10 |
Not supported 10 |
Not supported 10 |
ScrollBars |
Support |
Support |
Support |
Support |
Not supported 11 |
Not supported 11 |
Support |
Status |
Support |
Support 12 |
Support |
Not supported 13 |
Support |
Not supported 13 |
Not supported 13 |
TitleBar |
Not supported |
Not supported |
Not supported |
Not supported |
Not supported |
Not supported |
Not supported |
Toolbar |
Support |
Support |
Support |
Support |
Support 2 |
Not supported 14 |
Not supported 14 |
Top |
Support 3 |
Support 1 |
Support 3 |
Support 4 |
Support 4 |
Not supported 5 |
Not supported 5 |
Left |
Support 3 |
Support 1 |
Support 3 |
Support 4 |
Support 4 |
Not supported 5 |
Not supported 5 |
Width |
Support |
Support |
Support |
Support |
Support |
Not supported 6 |
Support |
Height |
Support |
Support |
Support |
Support |
Support |
Not supported 6 |
Support |
Top left |
Support 3 |
Support 4 |
Support 3 |
Support 4 |
Support 4 |
Not supported 5 |
Not supported 5 |
Width height |
Support |
Support |
Support |
Support |
Support 4 |
Support 1 |
Support |
Top Left width height |
Support |
Support 4 |
Support 3 |
Support 4 |
Support 4 |
Support 3 |
Support 4 |
In the table above, the level of support for each of the features parameter options for each browser, which requires special instructions, is as follows:
- "Callout 1": IE7 IE8 Firefox Chrome Safari, when the "menubar" option is "Yes", the menu bar is not displayed by default and you need to press the ALT key to display the menu bar, whereas when the "menubar" option is "no", even if you press Alt The key also does not display the menu bar.
- 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, if the set coordinate values are too large, the pop-up window may appear outside the screen's viewable range.
- "Callout 4": IE7 Firefox Safari Opera, using "Top" and "left" positioning, if the set of coordinate values is too large, the window will automatically adjust the "top" and "left" value, to ensure that the window appears normally in the screen visible area.
- "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 conjunction with the "Callout 5" note, the pop-up window in Chrome has to be assigned all regardless of whether you want to set the width height or the 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 show him, set "Location=yes" after the address bar will be automatically displayed.
- "Callout 9": In Chrome Opera, the menu bar is never displayed, regardless of how the "menubar" value is set.
- "Callout 10": In Firefox Safari Chrome Opera, the window can always be resized by the user regardless of how the "resizable" value is set.
- "Callout 11": In Safari Chrome, scroll bars are always visible, regardless of how the "scrollbars" value is set, in the presence of scroll bars on the page.
- "Callout 12": IE7 the "status" parameter hides the status bar by default in the Windows XP SP3 system, while the "status" parameter is not supported in the Windows Vista system default environment, the status bar is always visible. This is related to the default IE7 minor version number in both systems, which has a lower version number and a higher version number.
- "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 Sfeatures parameter support degree of the Window.Open method is very different and should be used with caution.
Solution Solutions
It is recommended that the following configuration string be recommended when using the Sfeatures parameter of the Window.Open method to ensure that all browsers behave basically the same:
" top=nInt,left=nInt,width=nInt,height=nInt,location=yes,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no
"
Original: http://www.w3help.org/zh-cn/causes/BX1053
Each browser has a different degree of support for the window feature sfeatures parameter of window.open ()