onunload event question
I have a function that checks to see if any data was changed on a page, and alerts the user if they are trying to leave the page without saving the data.
All works great in terms of prompting; but, I don't know what the code should be when they hit cancel. So, if a user edits a piece of text, tries to close the browser, then they get the alert (correct), they hit cancel as they forgot to save, but instead of the page just appearing, the browser still closes. Same thing happens for when they click a link, back, or any event of leaving the page. Hitting cancel needs to stop whatever they are trying to do, but I don't know what to put in the code.
if (document.getElementById("hidDataChanged").value == "Yes")
var boolLeavePage = confirm("You have unsaved data, are you sure you wish to leave the page?");
if (boolLeavePage == false)
Can someone help?
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)