Is there an On Browser Close???

I am trying to capture when the user closes the browser window. They are supposed to hit a logout button instead so I can update record changes, set session variables, etc. I have tried onbeforeunload, but this fires every time the page changes. I only need it to happen when the browser itself closes.

Is there a way to do this?

Thanx!

Comments

  • I don't know of anything beyond the onBeforeUnload that you've mentioned. Is there a reason, outside of resource use, that you don't want to update everytime they change pages? That's probably about the most reliable way to make sure things aren't lost. Also, have you tested onBeforeUnload beyond IE? In my testing it doesn't seem to work in NS 4.8, Mozilla or Opera.
    As an alternative, if everyone is on IE, you could run the user pages within a frame and use the onBeforeUnload within the frameset. If you create a frame that takes up 100% of the browser window, it's virtually unnoticeable. That would allow them to move about within the appropriate pages and only be updated on exiting your pages/frame. Anyway, this isn't pretty, but it basically works:


    Header

    function run_event() {
    alert("Boo!");
    }




    This document requires a browser that can view frames.






    Hope this helps.

    Jeff

    : I am trying to capture when the user closes the browser window. They are supposed to hit a logout button instead so I can update record changes, set session variables, etc. I have tried onbeforeunload, but this fires every time the page changes. I only need it to happen when the browser itself closes.
    :
    : Is there a way to do this?
    :
    : Thanx!
    :
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion