user2632735
user2632735

Reputation: 1

Javascript not working in Chrome

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

Answers (3)

sjain
sjain

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

Praveen
Praveen

Reputation: 56501

logout() !== Logout()

Try the below one

window.onbeforeunload = logout;
function logout()
  {
   window.location.href = "logout URL";
   return false;
  }

Upvotes: 0

Talha Akbar
Talha Akbar

Reputation: 10030

Your function name is Logout() not logout(). Case Sensitivity

Upvotes: 4

Related Questions