Firefox browser How to JS close the window of several workarounds

Source: Internet
Author: User

Today on the project has a page requirements in a few seconds after the automatic shutdown, thinking that it is relatively simple, with window.close () can be, but with ie/Google/Firefox to try, found that IE can, Google with the online compatibility method can also be achieved, but Firefox here stuck, can not be closed, A compatible code you see on the Web:

function Windowclose () {varBrowsername =Navigator.appname; if(browsername=="Netscape") {window.open ("','_self',"');    Window.close (); }    Else {        if(Browsername = ="Microsoft Internet Explorer") {Window.opener="Whocares"; Window.opener=NULL; window.open ("','_top');        Window.close (); }    }}

Try to find Firefox or not, and Baidu has a few posts, the following is my summary:

First, this method is simple and rough: Change the Firefox configuration file

Steps:
1. Enter About:config in the Address bar and return, warning confirmation
2, enter "Dom.allow_scripts_to_close_windows" in the filter, double-click to set this value to True
can be completed.

Note: Although this method can quickly solve the problem, but in the actual project, we could not ask each customer to change their own browser configuration file

Second, the use of JS in the window.open ()

Because it is found that Firefox must be JS open page, can be closed with window.close (), so that the window.open ("This page address") to jump to this page, test feasible

Third, the use of a label

Use a tag link to jump to this page, but need to use the target= "_blank" property to reopen the page, test feasible

There are three solutions, but there is no way to find out how Firefox has tried to close the page on this page, and it has yet to be researched, in the hope that God knows it can tell

Firefox browser How to JS close the window of several workarounds

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.