JavaScript closes the current page of window without prompting
- 2020-03-30 02:26:24
- OfStack
1. Js code to close the window without any prompt
2. Close the current page (with prompt under IE)
3. Custom prompt closed
4. When the user clicks the "close" button in the "maximize", "minimize" and "close" buttons of the browser, a closed confirmation dialog box also pops up
<a href="javascript:window.opener=null;window.open('','_self');window.close();"> Shut down </a>
2. Close the current page (with prompt under IE)
<a href="javascript:window.opener=null;window.close();"> Shut down </a>
3. Custom prompt closed
<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" button in the "maximize", "minimize" and "close" buttons of the browser, a closed confirmation dialog box also pops up
<body onbeforeunload="return ' Do you really want to close this window ?'">