21 Feb 2011 11:54 AM #1
Help managing onbeforeunload or onunload events browser
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]?
21 Feb 2011 12:43 PM #2
Any suggestion or recommendation will be appreciated!!!
1 Nov 2011 8:21 AM #3
Unfortunately, the implementation of onbeforeunload situation is totally up to the browser. I bumped into this too... So far, no news AFAIK.
1 Nov 2011 9:29 AM #4
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
By mankz in forum Community DiscussionReplies: 5Last Post: 17 Sep 2013, 12:59 PM
By rakesur in forum Ext 3.x: Help & DiscussionReplies: 1Last Post: 18 Nov 2009, 4:14 AM
By msobczak in forum Ext.nd for Notes/DominoReplies: 1Last Post: 10 Jul 2009, 8:52 PM
By rojar in forum Ext 1.x: Help & DiscussionReplies: 1Last Post: 3 Mar 2008, 6:49 PM