+ 5
Closing web tab
I've seen this on a few websites, where when you close a tab and an important process is running it asks the client if they want really want to leave. I would like to know if it's the web browser itself, or specific Javascript code. If it is Javascript code, what code would it be? and where can I read more on it?
4 Respuestas
+ 5
here's a snippet from Stackoverflow.com
window.onbeforeunload = function() { return "Hey, you're leaving the site. Bye!"; };
+ 4
@Limitless its a confirm box (javascript code)
here is a snippet copied from the javascript course:-
var result = confirm("Do you really want to leave this page?");
if (result == true) {
alert("Thanks for visiting");
}
else {
alert("Thanks for staying with us");
}
+ 4
So how do we determine if the user is trying to close the tab?
+ 3
@empty check the course !!!