Below function is working fine for IE, but not working for Mozilla and other browsers:
function CloseSession() { alert("Inside Close"); if ((window.event.clientX < 0) || (window.event.clientY<0)) { alert("Inside Events"); location.href = '/forms/sessionkill.aspx'; } }
What I am trying to do is, I have a button on a page after clicking on that button, a page in opened in new window having session, the session will be maintained until user closes the browser. on the new page there is right navigation which have different links for different pages. If I directly call my sessionkill.aspx it kills the session whenever a link is clicked on window unload function.
Advertisement
Answer
Mozilla does not set the global window.event
property.
I’d recommend using an AJAX framework, such as JQuery (or even Microsoft AJAX).
function CloseSession(event) { // use Mozilla event parameter, or window.event if that was not passed event = event || window.event; alert("Inside Close"); if ((event.clientX < 0) || (event.clientY<0)) { alert("Inside Events"); location.href = '/forms/sessionkill.aspx'; } }
Update: if you were using JQuery:
function CloseSession(e) { alert("Inside Close"); if ((e.pageX < 0) || (e.pageX < 0)) { alert("Inside Events"); location.href = '/forms/sessionkill.aspx'; } }