Member Avatar for Pityu
Pityu

Hey.
I have developed a jquery snippet, that creates a cookie if a window is opened. If only one is opened, and the user is attempting to close it, a confirm will show up to the user to log out first.
I would like to create an if, that will check if the user is attempting to reload or leave.
Now I use window.onbeforeunload.
I tried this:

if(!window.location.reload){
window.onbeforeunload = function(){
return "some message here";
}
}

But it will reload the page over and over again.
I don'thave any idea on how to do this.

Any suggestion?:D