Good day I want to show the warning message when user leaves the page with out submitting the form warning message should also be shown when user refreshes the page by pressing F5 I have done When user presses F5 it shows warning message
$(function () {
$(document).keydown(function (e) {
if ((e.which || e.keyCode) == 116) {
var FlagVal = $("#IsCaseInfoChanged").val();
return "You have not saved your data. Do you really want to leave this page?";
}
});
});
And the below code shows warning message 1. Currently for "IE" browser and "Chrome" browser if u don't provide proper URL in address bar than its not giving warning message to user for valid URL its working fine. For Browser like Firefox and Safari its working in both condition.
And In Firefox browser it is giving browser specific warning message not our costume message. For other browser it is working fine. how do i resolve it.
window.onbeforeunload = function (e) {
/* Getting flag value for Browser if it has been set to true or not */
/*if true show warning message*/
var evtobj = window.event ? event : e;
if (evtobj == e) {
if (!evtobj.clientY) {
return "You have not saved your data. Do you really want to leave this page?";
}
}
}