First, you can use window. close () to close the browser window, but it is invalid in firefox and Chrome, but it can be closed by some special means. First, IE can use window. close () to close the browser window, but it is invalid in firefox and Chrome.
The reason is:
By default, Firefox cannot close the browser window through scripts to prevent malicious script injection,
The adjustment method is to enter about: config in the url address bar,
Find dom. allow_scripts_to_close_windows in the configuration list.
Right-click the switch and modify the above false to true. The default value is false.
Chrome does not support this method by default, but it can also be disabled by some special means:
The Code is as follows:
Window. opener = null;
Window. open ('', '_ self ');
Window. close ();
When the parent element of the window is not created, the window is directed to itself and closed at the same time. In fact, it is similar to opening the current page with a script, and then closing the current page with a script, this method is recognized in W3C!
We cannot ask customers to change the browser configuration. 99% of users use the default configuration. This method can solve the problem that most browsers cannot close the current page, I don't know after 10 years (this is nonsense, hehe ).