TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ravi Patel
270
6.8k
1.4m
javascript ,jquery
Jul 21 2014 8:11 AM
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
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
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;
}
</script>
</head>
<body onbeforeunload="Logout()" onclick="clicked=true;">
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
Reply
Answers (
1
)
PhoneGap
How I can improve online customer support service on website