Hi,
I am working on the jquery. If user wants to navigate to any othere page then the confirm box will be displayed with the message
"Are you sure you want to navigate current page". For this i wrote below code
window.onbeforeunload = askconfirm;
window.doAskConfirm = true;
function askconfirm() {
if (doAskConfirm) {
if (confirm("Do you want to leave this page?") == true) {
} else {
window.onbeforeunload = null;
window.doAskConfirm = false;
}
}
}
$(document).ready(function () {
$("button").click(function () {
window.doAskConfirm = true;
if (this.id == "home")
document.location = '@Url.Action("Index", "Home")';
else if (this.id == "grp")
document.location = '@Url.Action("ViewGroup", "GroupMaintenance")';
else if (this.id == "client")
document.location = '@Url.Action("ClientMaintenanceHome", "ClientMaintenance")';
else if (this.id == "logout")
document.location = '@Url.Action("LogOut", "Login")';
else {
window.doAskConfirm = false;
return false;
}
});
});
My Question is how to handle cancel button because when i click on the cancel button script error is giving.
Can any body tell me how to handle cancel the confirm box.
Thanks
Kishore