JavaScript Silent Close window (compatible ie/firefox/chrome) _javascript tips

Source: Internet
Author: User
In Ie7/firefox 3.0/google Chrome passed the test
Closedemo.htm
Copy Code code as follows:

<script>
var browsername=navigator.appname;
if (browsername== "Netscape")
{
function Closeme ()
{
window.open (', ' _parent ', ');
Window.close ();
}
}
Else
{
if (browsername== "Microsoft Internet Explorer")
{
function Closynoshowsme ()
{
Window.opener = "Whocares";
Window.close ();
}
}
}
</script>
<input type= "button" value= "Close me 3" onclick= "Closeme ();" />

Attention
If you are using a Firefox browser you must make the following settings
1, in the Address bar input about:config and then enter, warning confirmation
2, enter "Dom.allow_scripts_to_close_windows" in the filter, double-click to set this value to True
can be completed.
Test comparison good code: feel netizens reply
<script type= "Text/javascript" > Function Closeme () {var browsername=navigator.appname; if (browsername==) Netscape ") {window.open (', ' _parent ', '); Window.close ();} else if (browsername==" Microsoft Internet Explorer ") {Windo W.opener = "Whocares"; Window.close (); } </script> <input type= "button" value= "Close me 3" onclick= "Closeme ();" />
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.