Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Firefox onbeforeunload problem

Posted on 2009-04-08
5
Medium Priority
?
2,853 Views
Last Modified: 2013-12-07
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

0
Comment
Question by:bahadirkocaoglu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 15

Expert Comment

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

on ff3 It works
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 24104291
Yes, because it does not depend on other scripts on that page.
0
 
LVL 2

Author Comment

by:bahadirkocaoglu
ID: 24110664
But it's working all pages. I want only window close, not on navigation.
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 500 total points
ID: 24114654
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
 
LVL 2

Author Closing Comment

by:bahadirkocaoglu
ID: 31568094
Thank you!
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn how to count occurrences of each item in an array.
How to create a custom search shortcut to site-search Experts Exchange using Google in the Firefox browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch your Bookmark Menu: Press 'Ctrl +…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question