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