window.onbeforeunload = askconfirm; window.doAskConfirm = true;
function askconfirm() { if (doAskConfirm) { if (confirm("Do you want to leave this page?") == true) { //they pressed OK } else { // they pressed Cancel 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; } }); });
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)