1. #1
    Sencha User jaadolio's Avatar
    Join Date
    Nov 2010
    Posts
    18
    Vote Rating
    0
    jaadolio is on a distinguished road

      0  

    Question Help managing onbeforeunload or onunload events browser

    Help managing onbeforeunload or onunload events browser


    Good Afternoon:

    I need some assistance regarding the use of standard onbeforeunload or onunload events.

    I have created an application that uses PHP sessions for users to login in which it includes a "logout" option to exit the website (destroying the session).

    However I need to be able to control when user clicks the browser's Close Button (X), so that I can activate a MessageBox confirmation advising the user correctly.

    I tried using Ext.EventManager registering the "beforeunload" event. It helps me control the closing action, but it displays the default confirm message from the browser:

    "Are you sure you want to navigate away from this page?... Press OK to continue, or Cancel to stay on the current page."


    According to some forums, this message is not able to be changed programmatically, but probably if I let this being managed like this, my users will get confused...

    Another thing is that "beforeunload" is not being activated in other browsers like Opera (vers. 11.01)

    Is there some special feature or event in ExtJS that can help me out with this like the one included on the Dojo Toolkit framework [dojo.addonUnload]?

    Thanks...

  2. #2
    Sencha User jaadolio's Avatar
    Join Date
    Nov 2010
    Posts
    18
    Vote Rating
    0
    jaadolio is on a distinguished road

      0  

    Default


    Any suggestion or recommendation will be appreciated!!!

  3. #3
    Sencha User
    Join Date
    Apr 2010
    Posts
    100
    Vote Rating
    0
    Dipish is an unknown quantity at this point

      0  

    Default


    Unfortunately, the implementation of onbeforeunload situation is totally up to the browser. I bumped into this too... So far, no news AFAIK.

  4. #4
    Sencha User darthwes's Avatar
    Join Date
    Mar 2010
    Posts
    633
    Vote Rating
    -13
    darthwes can only hope to improve

      0  

    Default


    The onbeforeunload event, as you've described, doesn't seem to be fired by all the browsers, anyway. On some, however, the event does fire, it's just synchronous, so you can't initiate an ajax request.

    What seems to work for me is to perform a synchronous XHR request, which, again, sucks, but IDK what else to do. That seems to catch the bulk of user logouts for me, but I don't have a lot of users on Opera, either.
    Wes

Similar Threads

  1. window.onbeforeunload
    By mankz in forum Community Discussion
    Replies: 5
    Last Post: 17 Sep 2013, 12:59 PM
  2. Performance issue with managing browser back/forward navigation in IE6
    By rakesur in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 18 Nov 2009, 4:14 AM
  3. onBeforeUnload
    By msobczak in forum Ext.nd for Notes/Domino
    Replies: 1
    Last Post: 10 Jul 2009, 8:52 PM
  4. browser events
    By rojar in forum Ext 1.x: Help & Discussion
    Replies: 1
    Last Post: 3 Mar 2008, 6:49 PM

Thread Participants: 2

Tags for this Thread