How to disable the browser window in firefox and Chrome is invalid _ basic knowledge

Source: Internet
Author: User
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 ).
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.