var validNavigation = false; var value = ""; var sessionId = "lhauntu3g4z3eighjyvu303g"; function endSession () { if ((value === null || value === "") && !validNavigation) { $.ajax({ url: '/' + culture + '/Account/LogOffUser', cache: false, async: false, type: "POST", }); } } function wireUpEvents() { if (navigator.userAgent.toLowerCase().indexOf('firefox') > -1) { window.onBeforeUnload = function () { if (!validNavigation) { endSession(); } }; } if ($.browser.msie) { window.beforeunload = function() { if (!validNavigation) { endSession(); } }; }else { window.onbeforeunload = function () { if (!validNavigation) { endSession(); } }; } // Attach the event keypress to exclude the F5 refresh $(document).bind('keypress', function (e) { if (e.keyCode == 116) { validNavigation = true; } }); // Attach the event click for all links in the page $("a").bind("click", function () { validNavigation = true; }); // Attach the event submit for all forms in the page $("form").bind("submit", function () { validNavigation = true; }); // Attach the event click for all inputs in the page $("input[type=submit]").bind("click", function () { validNavigation = true; }); jQuery('form').submit(function() { jQuery(window).unbind("beforeunload"); jQuery(window).unbind("onbeforeunload"); }); } //});