Firefox onbeforeunload problem

Hi there,

I want logout users on browser window on close.

How can I do this?

I did try 'onbeforeunload' and 'onunload', but doesn't work.

(logout.php - only update an db-table)

This code working on IE. But no FF

(I'm so sorry for my bad english)

My javascript code:
<script type="text/javascript">
window.onbeforeunload = function() {
	var myRequest = new Request( { method: 'get', url: 'logout.php' } ).send();
}
</script>

Open in new window

LVL 2
bahadirkocaogluAsked:
Who is Participating?
 
Michel PlungjanIT ExpertCommented:
This is an extremely frequently asked question
your application should NOT need to have the user log out on close and the browsers are notoriously not telling you when they close

IE can be detected with some silly event location script and FF cannot as far as I know.

Fix your application instead of relying on being told that the browser closed

That said, have a look here if any work for you. If they do let us know too.

http://www.google.com/search?q=php+detect+browser+close
0
 
fsze88Commented:
I tested
<script type="text/javascript">
window.onbeforeunload = function() {
        alert('abc');
}
</script>

on ff3 It works
0
 
Michel PlungjanIT ExpertCommented:
Yes, because it does not depend on other scripts on that page.
0
 
bahadirkocaogluAuthor Commented:
But it's working all pages. I want only window close, not on navigation.
0
 
bahadirkocaogluAuthor Commented:
Thank you!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.