+ 1

How do you alert a person when the person is leaving the page

28th Dec 2016, 7:02 AM
Owen Jay
Owen Jay - avatar
4 odpowiedzi
+ 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
2nd Jan 2017, 9:44 AM
Sagar D
Sagar D - avatar
+ 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?")">
28th Dec 2016, 3:24 PM
David Sebastian Keshvi Illiakis
David Sebastian Keshvi Illiakis - avatar
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.
28th Dec 2016, 9:01 AM
Uran Kajtazaj
Uran Kajtazaj - avatar
0
You could make use of the onunload() event. Reference: http://www.w3schools.com/jsref/event_onunload.asp
6th Feb 2017, 5:35 PM
Ronnell Evans
Ronnell Evans - avatar