JS open new window and Close Window

Source: Internet
Author: User

1.open.html

<SCRIPT type = "text/JavaScript">
<! --
Function OpenWindow (){
Window. Open ("new.html", "newwindow", "width = 200, Height = 100, toolbar = No ");
}
// -->
</SCRIPT>
<A href = "#" onclick = "OpenWindow ()"> open a new window </a> <br/>
<A href = "new.html" target = "_ blank"> hyperlink opens a new page in a new window </a> <br/>
<A href = "new.html" target = "_ parent"> the hyperlink opens a new page in the parent window. </a>

2.new.html

<A href = "javascript: window. Close ()"> close the window </a>
<A href = "javascript: Self. Close ()"> close the window </a>

You can use the open method and open in "_ blank" to close it in a new window, but the open in "_ parent" is still disabled in Firefox.

Now

Therefore, when using the close method of window in Firefox, you should note that it is different from IE: The page opened in the parent window cannot be closed.

Method.

Then I went to Google to search for it. The reason why window. Close is not available in Firefox is that Firefox cannot close users by default.

You can set Firefox as follows:

Open Firefox and enter about: config in the address bar.

Find Dom. allow_scripts_to_close_windows and change it to true.

Now you know why. The article has a good article, which is excerpted as follows:

As we all know, in Javascript, window. Close () is used to close the window, and both IE and Firefox support it. To achieve

Users have absolute control over the browser. When close is used in IE to close a non-open window, a dialog box is displayed asking users. Sometimes I

We don't want to do this again, but how can we remove this box and use the following code?

<Script language = "JavaScript" type = "text/JavaScript">

Function closewindow (){

Window. Open ('', '_ parent ','');

Window. Close ();

}

</SCRIPT>
<A href = "javascript: closewindow ();"> Close Window </a>

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.