Use JavaScript to close this window does not eject the query box method _javascript Tips

Source: Internet
Author: User

Everyone knows that window.close () is used to close windows, and both IE and Firefox are supported.

In order to achieve the user's absolute control of the browser, ie in the closed open window with close to pop up a dialog box to ask users, how to remove this box, please see the following code.

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

It is OK to add Window.top.opener = null before window.close.

Some people say that Firefox does not support close, in fact, this is wrong, the reason why Window.close in Firefox can not be used, because the Firefox default can not shut down the user's open Web page, so set up Firefox.

Open Firefox, enter about:config in the address bar
Locate the Dom.allow_scripts_to_close_windows and change to true.
What you need to talk about is the hassle of not having a pop-up dialog box in Firefox.

<script>
function A () {
window.open (', ' _parent ', ');
Window.opener = window;
Window.close (); 
}
</script>

Run this again and it will be closed under FF.

See these, if let the customer to set up, is equal to do not do this function, so said the result is not very satisfied, do not know if there is no other good alternative method.

PostScript: You can close the current page by opening a new window and then closing the page. Thank you, Strangebank. But the strange thing is that yesterday I did not succeed with the FF2 test, and today I succeeded with 3. What a heck of a thing, today on a colleague's machine with 2 to do the experiment, again. But it's good to solve the problem in the morning. ^_^

Index.html

<a href= "c.html" target= "_blank" >ddddddddd</a>

C.html

<a href= "Javascript:window.open (', ' _parent ', '); Window.close ();" >close window</a>
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.