Link to home
Start Free TrialLog in
Avatar of bahadirkocaoglu
bahadirkocaogluFlag for Türkiye

asked on

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

Avatar of Kin Fat SZE
Kin Fat SZE
Flag of Hong Kong image

I tested
<script type="text/javascript">
window.onbeforeunload = function() {
        alert('abc');
}
</script>

on ff3 It works
Yes, because it does not depend on other scripts on that page.
Avatar of bahadirkocaoglu

ASKER

But it's working all pages. I want only window close, not on navigation.
ASKER CERTIFIED SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you!