How to close this window with javascript without a pop-up dialog box _ javascript skills

Source: Internet
Author: User
When close is used in ie to close a non-open window, a dialog box is displayed asking users how to remove this box. In window. add window before close. top. openernull is enough for everyone to know window. close () is used to close the window, and both ie and firefox support.

In order to achieve absolute control over the browser, a dialog box pops up asking the user how to remove this box when closing a non-open window with close in ie. See the following code.

function winClose(){ window.top.opener = null; window.close(); }

Add window. top. opener = null before window. close.

Some people say that firefox does not support close. In fact, this is an error. The reason why window. close cannot be used in firefox is that firefox cannot close the webpage opened by users by default. You can set firefox in this way.

Open firefox and enter about: config in the address bar.
Find dom. allow_scripts_to_close_windows and change it to true.
It must be said that there is no trouble to bring up a dialog box in firefox.

《script》function a(){window.open('','_parent','');window.opener = window;window.close(); }《script》

Run the command again to disable it in ff.

When we see this, if we ask the customer to set it, it means that this function is not done, so we are not satisfied with the results, and we do not know whether there are other good alternatives.

Note: you can close the current page by opening a new window and closing the page. Thank you, strangebank. However, it is strange that I did not succeed in the ff2 test yesterday. Today I succeeded in using 3. Today, I tried to use 2 on my colleague's machine. Now I can try again. But it is good to solve the problem early in the morning. Pai_^

Index.html

ddddddddd

C.html

Close Window

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.