<script type="text/javascript">
var sessionID = getQuerystring('SessionID');
var cookieSessionID = getCookie('session');
var validNavigation = false;
function endSession() {
setCookie('session', sessionID, 1);
var cookieSU = getCookie('session');
if (cookieSU != null) {
getSyncData('strSessionId=' + sessionID, 'UpdateUserLogoutSession');
}
}
function wireUpEvents() {
window.onbeforeunload = function () {
if (!validNavigation) {
endSession();
}
}
$('document').bind('keypress', function (e) {
if (e.keyCode == 116) {
validNavigation = true;
}
});
$("a").bind("click", function () {
validNavigation = true;
});
$("form").bind("submit", function () {
validNavigation = true;
});
$("input[type=submit]").bind("click", function () {
validNavigation = true;
});
}
$(document).ready(function () {
if (cookieSessionID == null || cookieSessionID != sessionID) {
} else {
if (cookieSessionID == sessionID) {
getData('strSessionId=' + sessionID, 'UpdateUserResetSession', function (result) {
if (result['Exception']) { };
});
}
}
wireUpEvents();
});
function setCookie(c_name, value, exdays) {
var exdate = new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString());
document.cookie = c_name + "=" + c_value;
}
function getCookie(c_name) {
var i, x, y, ARRcookies = document.cookie.split(";");
for (i = 0; i < ARRcookies.length; i++) {
x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
x = x.replace(/^\s+|\s+$/g, "");
if (x == c_name) {
return unescape(y);
}
}
}
</script>
Hey guys here i am calling
UpdateUserLogoutSession
in
window.onbeforeunload
event...
Now the problem is this works great on IE and Chrome..but it doesnt work on Firefox browser...
This function identify whether the page is REFRESHED or Closed........
So i want to use
UpdateUserResetSession
on Refresh event and
UpdateUserLogoutSession
on close..!
Is there a way to do this in Firefox?
And Why it is not working?
One more thing....if i put
alert("hi");
after
setCookie('session', sessionID, 1);
var cookieSU = getCookie('session');
if (cookieSU != null) {
getSyncData('strSessionId=' + sessionID, 'UpdateUserLogoutSession');
}
it just works great..but when i try without alert..it doesnt work?
Whats the problem?