I'd like to make an exit popup on my website. I've prepared my modal but can't find "a good way" to detect a moment when a user is about to leave the website. I've read some other posts on this subject and found this piece of code:
$(document).ready(function() {
$(document).mouseleave(function(e) {
if(e.clientY < 0) {
$('#exit').modal('show')
}
});
});
Unfortunately this solution doesn't work on IE and Edge. What's the better way of doing it?
UPDATE: Let me be more precise. I want to achieve something like this. I assumed that the best way is to detect when a mouse leaves a document.