Window.close (); Close the browser window JS Code Summary Introduction
Serial Number |
Close Code |
need to confirm |
no effect whatsoever |
No confirmation required |
Test |
1 |
Window.close () |
IE7 |
Firefox,chrome, Safari |
Opera |
Close |
2 |
Window.opener=null; window.open (', ' _self '); Window.close (); |
|
Firefox |
Ie7,opera, Chrome,safari |
Close |
3 |
window.open (', ' _self '); Window.close (); |
|
Firefox |
Ie7,opera, Chrome,safari |
Close |
4 |
Window.opener=null; Window.close (); |
IE7 |
Firefox,safari |
Chrome,opera |
Close |
5 |
var opened=window.open (' About:blank ', ' _self '); Opened.opener=null; Opened.close (); |
|
Firefox |
Safari,ie7, Chrome,opera |
Close |
6 |
var opened=window.open (' About:blank ', ' _self '); Opened.close (); |
|
Safari,firefox |
Firefox,ie7, Chrome,opera |
Close |
Open a page in a variety of ways and then close it with Window.close () and perform differently in each browser. If you enter the URL directly in the address bar, Firefox Chrome Safari cut off the page with Window.close () invalid. Again as Ctrl + click on the link Open window, Firefox can not be invoked by calling Window.close () to close.
The difference is the following table:
|
Address bar Input URL |
Click | on the link
Ctrl + click Link |
window.open |
window.showModalDialog |
IE6 |
Prompt window close |
Close directly |
Close directly |
Close directly |
Close directly |
Ie7/8 |
Close directly |
Prompt window close |
Prompt window close |
Close directly |
Close directly |
Firefox |
Do not close, no hint |
Close directly |
Do not close, no hint |
Close directly |
Close directly |
Safari |
Do not close, no hint |
Close directly |
Close directly |
Close directly |
Close directly |
Chrome |
Do not close, no hint |
Close directly |
Close directly |
Close directly |
Close directly |
Opera |
Close directly |
Close directly |
Close directly |
Close directly |
does not support |
Firefox can not close the possible reasons:
Not JS code window.close () problem, but Firefox configuration problem, the solution is as follows: in the Firefox address bar input about:config in the configuration list to find Dom.allow_scripts_to_close_ The select switch of the Windows Point right button modifies the above false to true. Note: Default is false to prevent script from messing up windows
Additional code: Window.opener = null;//in order to not appear the prompt box Window.close ();//Close the window
The above article Window.close (); Close the browser window JS Code Summary is a small series to share all the content, hope to give you a reference, but also hope that we support the cloud-dwelling community.