javaScript close your browser (no pop-up boxes)

A JavaScript script, is responsible for closing the window, if the page is not opened by script (window.open ()), calling window.close () to close the window before the script, you must first window.opener target set to null, otherwise the browser (IE7, IE8) will pop up a dialog box is closed OK.

 Solutions in the following ways:

 1. Point to shut itself down method 

 <script language="javaScript"> 

function closeWindow() 

 {  

window.opener = null;  

window.open(' ', '_self', ' '); 

  window.close();

 } 

</script> 

 <Input type = 'button' value = 'Close' onClick = "closeWindow ()"> 

 2. Method closed top frame 

 <script language="javaScript"> 

function closeWindow() 

 { window.opener = null; 

 window.open('', '_top', ''); 

 window.parent.close();

 } 

 </script> 

 <Input type = 'button' value = 'Close' onClick = "closeWindow ()"> 

 3. There is also an online common approach, but it seems to IE8 but does not work in IE6 is closed in simple direct approach

 window.opener = null;

 window.close(); 


Reproduced in: https: //juejin.im/post/5d085dbe6fb9a07ec07fc14f

Guess you like

Origin blog.csdn.net/weixin_34272308/article/details/93178001