?
Solved

Firefox onbeforeunload problem

Posted on 2009-04-08
5
Medium Priority
?
2,844 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
This article discusses how to implement server side field validation and display customized error messages to the client.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

771 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