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
Release: 2016-05-16 17:08:51
Original
1577 people have browsed it

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();

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template