Reputation: 1
window.onbeforeunload = function() { logout();};
function Logout()
{
window.location.href = "logout URL";
return false;
}
My requirement is: when user clicks close button, user should be logged out. It is working fine in IE. But not working in Chrome.
Can any one please suggest.
Upvotes: 0
Views: 230
Reputation: 23344
Try,
window.onbeforeunload = logout;
function logout() {
window.location.href = "logout url";
return false;
}
UPDATE:
First is to check whether logout function is ever getting called by putting alerts in
logout function or if you are using newer versions of chrome then use console.log('called')
.
You can try this alternative to check:
window.onbeforeunload = function() {
logout();
return null;
}
function logout() {
window.location.href = "logout url";
}
Upvotes: 1
Reputation: 56501
logout() !== Logout()
Try the below one
window.onbeforeunload = logout;
function logout()
{
window.location.href = "logout URL";
return false;
}
Upvotes: 0
Reputation: 10030
Your function name is Logout()
not logout()
. Case Sensitivity
Upvotes: 4