i want to call logout page on browser close or tab close?
why this code is not working in Firefox an and google chrome ? but working in IE on Browser close or tab close
var clicked = false;
function CheckBrowser() {
if (clicked == false) {
window.location = "../Security/logOut.aspx";
// Browser closed
}
else {
alert('false');
redirected
clicked = false;
}
}
function Logout() {
if (clicked == false)//browser is closed
{
//window.location = "../Security/logOut.aspx";
alert('close the browser?');
var request = GetRequest();
alert('close the browser'+request );
request.open("GET", "../Security/logOut.aspx", true);
request.send();
}
}
function GetRequest() {
var xmlHttp = null;
try {
// Firefox, Opera 8.0+, Safari
xmlHttp = new XMLHttpRequest();
}
catch (e) {
//Internet Explorer
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}

Pradeep ShetPosted Jul 21, 2014, 8:53 AM
why dont you use Jquery for this instead of using this lengthy code.
Import the jquery library first and use $.ajax() method
Pass the required parameter to this method and your code will run irrespective of browser.
Try this one...
If this answered your question mark it answered..