In body tag code: onbeforeunload="MyUnloadCheck()"
function MyUnloadCheck() {
event.returnValue = "You may have unsaved data ..."
}
The browser will display :
'Do you want to navigate away from this page?'
'You may have unsaved data'
'Hit Ok or cancel'
If you do not return a value in event.returnValue property,
browser will not display the message.
If you want to conditionally return a value if the page is dirty, create a new function on the fly after detecting it is dirty, as follows:
document.body.onbeforeunload=new Function("MyUnloadCheck()")
SS
|