Issue
so I'm making a drawing app. the problem is, when the user accidentally closes or refreshes the page, all the drawings will be lost. So I made a confirmation box that will confirm if the user really wants to close the page.
I have tried like this:
if (window.onbeforeunload == true ) {
confirm("Change are still not saved. Are you sure?")
}
But it doesn't work. Then what is the best solution to solve this problem?
Solution
onbeforeunload
is a function which is called when leaving the page. So you have to define it.
window.onbeforeunload = function()
{
return "Change are still not saved. Are you sure?";
};
Answered By - flappix Answer Checked By - Senaida (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.