Calling Logout on closing my browser window

Posted on 2003-03-21
Medium Priority
Last Modified: 2010-08-05
want to call my logout servlet if someone hits browser close button.
I tried all javascript combinations with onUnLoad() window.close() etc but nothing wrks as these events gets fired even on refresh and changing the locationof the url.

I was giving up when i saw the implementation in citibanks website. If anyone has account with citibank then u can check it out.
I tried to look into the view source but coulnd't make out anything..

any ideas will be highly appreciated ..!!!
Question by:agsingh
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
  • 3
  • 2
LVL 46

Expert Comment

ID: 8181141
One way to do this is to use frames with all of your pages in the site contained within one master frame. You only call the logout script when the frame is closed.

Fritz the Blank

Author Comment

ID: 8181322
i already have my application running. I cannot implement frames now.
LVL 46

Expert Comment

ID: 8181394
That is the only way that I know how to do this.

Fritz the Blank
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 8212517
Is there any way i can catch only browser close ie some javascript that works only when browser is closed and never in other case.
LVL 46

Accepted Solution

fritz_the_blank earned 400 total points
ID: 8212592
I am afraid not. All you can really do is to catch the onUnLoad() event, and that will fire regardless of whether the window was closed, someone moved on to another page, or if the application exits.

Fritz the Blank
LVL 16

Expert Comment

ID: 10149263
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: fritz_the_blank {http:#8212592}

Please leave any comments here within the next seven days.

EE Cleanup Volunteer

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
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

801 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