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