I am having two frames, upper frame contains some action button like add. edit. The lower frame contains forms to get user details. Consider that i have edited some contents in the lower frame and not clicked save button in the lower frame. And I am trying to click add/edit button from upper frame. using onunload event i will call javascript function which alert the user saying that user details not saved and should not proceed further. But in my case only alerting is happened and form loaded based on button clicked.
How can I stop the form without loading.
<body onunload="return sample()">
<script language='javascript'>
user_flag = 1;
function sample () {
if ( user_flag == 1 )
var answer = confirm ( 'You havent saved the form contents Want to proceed further');
if ( answer ) {
document.form.submit();
} else {
return false;
}
}
</script>


