1. JS code that closes the window without any prompts
The code copy is as follows:
<a href="javascript:window.opener=null;window.open('','_self');window.close();">Close</a>
2. Close the current page (with prompts under IE)
The code copy is as follows:
<a href="javascript:window.opener=null;window.close();">Close</a>
3. Custom prompts are closed
The code copy is as follows:
<script language="javascript">
function custom_close() {
if (confirm("Are you sure you want to close this page?")) {
window.opener = null;
window.open('', '_self');
window.close()
} else {}
}
</script>
<input id="btnClose" type="button" value="Close this page" onClick="custom_close()"
/>
4. When the user clicks the "Close" buttons in the "Maximize", "Minimize" and "Close" buttons of the browser, a closed confirmation dialog box will also pop up.
The code copy is as follows:
<body onbeforeunload="return 'Do you really want to close this window?'">