Below I will bring you a summary of window.close(); closing the browser window js code. Let me share it with you now and give it as a reference for everyone.
window.close(); Close the browser window js code summary introduction
serial number | Close Code | Requires confirmation | No effect | No need to confirm | Test |
---|---|---|---|---|---|
window.close() | IE7 | firefox,chrome, safari | Opera | Close | |
window.opener=null; window.open('','_self'); window.close(); | firefox | IE7,Opera, chrome,safari | Close | ||
window.open('','_self'); window.close( ); | firefox | IE7,Opera, chrome,safari | Close | ||
window.opener=null; window.close(); | IE7 | firefox,safari | chrome,Opera | Close | |
var opened=window.open('about:blank','_self'); opened.opener=null; opened.close(); | firefox | safari,IE7, chrome,Opera | Close | ||
var opened=window.open('about:blank','_self'); opened.close(); | safari,firefox | firefox,IE7, chrome, Opera | Close |
Enter the URL in the address bar | Click the link | Ctrl key click the link | window.open | window.showModalDialog | |
---|---|---|---|---|---|
IE6 | Prompt window to close | Close directly | Close directly | Close directly | Close directly |
IE7/8 | Close directly | Close the prompt window | Close the prompt window | Close directly | Directly Close |
Firefox | Do not close, no prompt | Close directly | Do not close, no prompt | Close directly | Close directly |
Safari | Do not close, no prompt | Close directly | Close directly | Close directly | Close directly |
Chrome | Do not close, no prompt | Close directly | Close directly | Close directly | Close directly |
Opera | Close directly | Close directly | Close directly | Close directly | Not supported |
Cannot be closed under firefox Possible reasons:
It is not a problem with the JS code window.close(), but The solution to the Firefox configuration problem is as follows: Enter about:config in the Firefox address bar. Find dom.allow_scripts_to_close_windows in the configuration list, right-click and select Change the above false to true. Note: The default is false, which is to prevent the script from closing the window randomly
Attached code: window.opener = null;//In order not to appear the prompt box window.close();//Close the window
The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.
Related articles:
Detailed introduction to the native and powerful DOM selector querySelector (code attached)
##javascript replace( ) Parameter usage when the second parameter is a function (detailed explanation for everyone)
detailed explanation of javascript prototype prototype (basic course)
The above is the detailed content of window.close(); Close browser window js code summary (detailed explanation). For more information, please follow other related articles on the PHP Chinese website!