In the html page shown,where is window.onbeforeunload = confirmExit
code to be placesd so that when validate div is shown the alert message does not appear when the user clicks on cancel or save button.And if the user clicks or any other link the alert message should be shown
If any other link is clicked makeajaxcall() function should be called and then continue
<div id="start" ></div>
<div id="validate" >
<input type="button" /value="cancel" onclick="window.locatcation='cancel()'">
<input type="button" /value="save" onclick="save()">
</div>
<div id="confirm" ></div>
<input type="hidden" name="localchanges" id="localchanges" value="1">
<script>
function cancel()
{
$('lovalchanges').val('0');
makeajaxcall();
}
function makeajxcall()
{
send request to server and get response
}
$(document).ready({
if(load_flag == 2)
{
$("#validate").css({'display':block});
$("#start").css({'display':none});
$("#confirm").css({'display':none});
window.onbeforeunload = confirmExit ;
}
});
function confirmExit()
{
var ele = document.getElementById ("localchanges") ;
if (ele.value == "1")
return "You have not saved any change made . Discard Changes ?" ;
}
</script>