I have a confirm dialogue bound to the onUnload() handler asking the user if s/he wants to leave the current page. If cancel is pressed, the document stops on the current page, as it is supposed to. However, if after this happens, the user clicks on a link to another page again, the dialogue box doesn't execute. It's as if the property of the page that records the loaded/unloaded status is stuck in unloaded, even though the current page is still there. Here's the code:
form_dirty = true;
window.onunload = warn_form_data_loss;
function warn_form_data_loss ()
{
if ( form_dirty == true )
{
var answer = ( confirm( "WARNING: You are about to navigate away from the current page, which may result in data loss. Would you like to proceed?" ) );
if (answer)
{
}
else
{
document.execCommand('Stop');
}
}
}
Normally this wouldn't be too much of a problem, but never underestimate the stupidity of you user
...Any ideas?
form_dirty = true;
window.onunload = warn_form_data_loss;
function warn_form_data_loss ()
{
if ( form_dirty == true )
{
var answer = ( confirm( "WARNING: You are about to navigate away from the current page, which may result in data loss. Would you like to proceed?" ) );
if (answer)
{
}
else
{
document.execCommand('Stop');
}
}
}
Normally this wouldn't be too much of a problem, but never underestimate the stupidity of you user