Windows silently closes the page

Source: Internet
Author: User

Today encountered a problem, the need to automatically close the Web page, the Internet to find a method, has been testing in Firefox, has not responded, thought to write wrong, and later found that Firefox needs to be set up (after the article provides methods), IE can be used normally ...

Some of the code is provided below:

To automatically close the page, you can use the following code:

1 <input type= "button" onclick= "Clickwindow ()" value= "click"/>23  <script Language= "JavaScript" type= "Text/javascript" >4         function  closewindow ()5          {6       window.close (); 7         }8  

However, the dialog box for closing the window will pop up, and if you do not need this dialog box, you can do so as follows:

  1  <input type=" button "onclick=" CloseWindow () "value=" click "/>< Span style= "color: #008080;" > 2   3  <script language= "JavaScript" type= "Text/javascript" > 4  function   CloseWindow ()   5   {  6  Window.opener =null  ;   window.open (', ' _self ', '    Window.close ();   "  10
         </script> 

This will allow you to close the window automatically. If you need to shut down periodically, you can match settimeout timing:

1 <input type= "button" onclick= "CloseWindow ()" value= "click"/>23 <script> 4     var closewindow=function() {5         window.opener=null; 6             window.open (', ' _self ', '); 7             SetTimeout (' Window.close () ', +); 8     }9 </script>    

When you click the button, the window will automatically close after 1s without prompting.

  

The above automatically shut down the code, IE can run normally, if you are using the Firefox browser must do the following settings
1. Enter About:config in the Address bar and return, warning confirmation
2, enter "Dom.allow_scripts_to_close_windows" in the filter, double-click to set this value to True
can be completed.

Well-compatible code reference (reference only, not tested):

Http://www.jb51.net/article/20092.htm

Windows silently closes the page

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.