+ 5
How to create an alert box that would visible at end for users
#endalert
2 odpowiedzi
+ 3
window.onbeforeunload=function(){
return "foo?" // if you want a prompt, return something
}
...works for me here. Probably best used to rescue users from accidentally losing unsaved work.
Using it to trap users on your pages will just alienate your audience.
I use this event to stop timers (clearInterval, clearTimeout, cancelAnimationFrame).
+ 1
There is an event listener about leaving the current page. But such malicious act will be blocked by modern browsers, hence your attempt will not be effective even if the syntax is all correct.