How to stop browser from closing using Javascript? - Dev Articles
Derived from that article is the simplified version we will use:
Currently this fires a new window with my site but with the prevelance of pop-up blockers don't expect this to be terribly effective.
<script>
var needToConfirm = false;
window.onbeforeunload = confirmExit;
function confirmExit()
{
//alert(needToConfirm);
if (needToConfirm)
{
window.open("http://cstech.no-ip.com");
//return "[Unremark this line to show the customized confirm dialog with OK/Cancel options.]";
}
}
needToConfirm = true;
</script>
No comments:
Post a Comment