Home  >  Article  >  Web Front-end  >  JavaScript silently closes the window (compatible with IE/Firefox/Chrome)_javascript tips

JavaScript silently closes the window (compatible with IE/Firefox/Chrome)_javascript tips

WBOY
WBOYOriginal
2016-05-16 18:58:171083browse

Passed the test in IE7/ Firefox 3.0/ Google Chrome
CloseDemo.htm

Copy the code The code is as follows:

<script> <br>var browserName=navigator.appName; <br>if (browserName=="Netscape") <br>{ <br>function closeme() <br>{ <br>window. open('','_parent',''); <br>window.close(); <br>} <br>} <br>else <br>{ <br>if (browserName=="Microsoft Internet Explorer ") <br>{ <br>function closynoshowsme() <br>{ <br>window.opener = "whocares"; <br>window.close(); <br>} <br>} <br>} <br></script>


Note"
If you are using Firefox browser, you must make the following settings
1. Enter about:config in the address bar and press Enter, confirm the warning
2. Enter "dom.allow_scripts_to_close_windows" in the filter, double-click it. Set this value to true
and you’re done
The code is easier to use for testing: I feel like netizens responded

[Ctrl A select all Note: If you need to introduce external Js, you need to refresh to execute
]
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn