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 the code code as follows:
function CloseWin()
{
window.opener=null;
window.open('','_self');
window.close();
}
Example:
XML/HTML code
1.<input type=button value="Close" onclick="CloseWin()">
For the parent window, open the child window, click the child window to close, and close the parent window at the same time:
var windowParent = window.opener;
windowParent.opener = null;
windowParent.open('', '_self');
windowParent.close();