Home >Web Front-end >JS Tutorial >JS sample code to close the web page window without prompting_javascript skills

JS sample code to close the web page window without prompting_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:08:511559browse

In IE7 and IE8, the current window or tab can be closed using the close() method provided by JavaScript, but an annoying dialog box is prompted. After looking for the code, I can finally close it directly without prompting.

JavaScript code

Copy code The code is as follows:

function CloseWin() 
{ 
window.opener=null; 
window.open('','_self'); 
window.close(); 
} 

Example:

XML/HTML code
1.

For the parent window to open the child window, click the child window to close, Operations to close the parent window at the same time:
var windowParent = window.opener;
windowParent.opener = null;
windowParent.open('', '_self');
windowParent.close();

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn