+ 1
How do you alert a person when the person is leaving the page
4 Answers
+ 2
alert(); function is used only to give some message to the user. it has only one button 'OK' . Thus if u use alert(); ...u can't prevent user from leaving the page.
instead use confirmation dialog box.
confirm(); returns true if user press 'OK' button and returns false if user press 'Cancel' button.
var val = confirm(" Do you want to leave the page ");
this creates a confirmation dialog box.
thus based on the users input u can continue
+ 1
Leaving the page? Do you mean something like going to another page? If so, it is simply <a href="http://google.com" onclick="alert("Leaving already?")">
0
if the cursor is not on the webpage show an alert but only once.
i know you can do it with javascript or jquery.
0
You could make use of the onunload() event. Reference: http://www.w3schools.com/jsref/event_onunload.asp