


JavaScript closes the current page (window) without any prompts_javascript tips
May 16, 2016 pm 04:54 PM1. JS code to close the window without any prompt
< ;a href="javascript:window.opener=null;window.open('','_self');window.close();">Close</a>
2 .Close the current page (prompt under IE)
< a href="javascript:window.opener=null;window.close();">Close</a>
3. Custom prompt to close
<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 among the "Maximize", "Minimize", and "Close" buttons of the browser, a closing confirmation dialog will also pop up. Box
<body onbeforeunload="return 'Really want to Close this window?'">

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

What is the shortcut key for full screen in Windows 7?

How to set Google Chrome to open a new window every time

What should I do if the Win7 taskbar is displayed in the right window of the desktop?

Windows 10 window color setting tutorial

How to close computer game advertising pop-ups

How to fix a window stuck in airplane mode on Windows 10

How to open two independent windows in Excel? How to open excel windows independently without overlapping

How to use keyboard shortcuts to switch between application windows in Ubuntu Unity?
