During project creation, you can click Text on the page to exit the browser window! However, the closing effect of the browser is inconsistent!
The demo introduced below can normally close mainstream browsers such as IE and chrome! However, Firefox is implemented by opening an empty page! If you want to achieve the same effect as IE, You need to enable the corresponding permissions!
Perform the following operations:
Open Firefox and enter about: config in the address bar.
Find Dom. allow_scripts_to_close_windows and change it to true.
However, the page is made for the user experience. This method requires the user to change the settings is often not desirable! So here I will replace it by opening an empty page!
The demo is as follows:
<! Doctype HTML> <HTML lang = "En-us"> // Determine whether it is ie If (navigator. useragent. indexof ("MSIE")> 0 ){
// Determine whether it is IE6 if (navigator. useragent. indexof ("MSIE 6.0")> 0) {window. opener = NULL; window. close ();} else {window. open ('', '_ top'); window. top. close ();}}
// Determine if it is Firefox else if (navigator. useragent. indexof ("Firefox")> 0) {window. Location. href = 'about: blank ';}
// Other mainstream browsers such as chrome and Safari else {window. opener = NULL; window. open ('', '_ Self',''); window. close () ;}</SCRIPT>
The demo above can basically solve the function of closing the current window of the browser. As for Firefox, it is a pity!
Windows close method compatible with all browsers