Results 1 to 6 of 6

Thread: window.onbeforeunload

  1. #1
    Sencha - Community Support Team mankz's Avatar
    Join Date
    Nov 2007
    Location
    Stockholm, Sweden
    Posts
    3,015
    Vote Rating
    182
      0  

    Default window.onbeforeunload

    I'm having some trouble grasping how onbeforeunload works (I'm using FF3). I want to prompt the user if unsaved changes exist when they try to leave my page. My handlers are called correctly in both scenarios below, I've tested with an alert which is shown as expected.

    This version works, I get a confirm popup, but using this will wipe out any previously registered handlers. Maybe Ext will do some cleaning on beforeunload (right now it looks like Ext cleans up on unload event) and I don't want to overwrite previously registered handlers.
    Code:
    window.onbeforeunload = this.onBeforeUnload.createDelegate(this);
    This version does not work, nothing happens when I leave the page
    Code:
    Ext.EventManager.on(window, 'beforeunload', this.onBeforeUnload, this);
    The event handler
    Code:
    onBeforeUnload : function(evt) {
                    return "message";
            }
    Does anyone know why this doesn't work?
    Last edited by mankz; 26 Mar 2009 at 6:42 AM. Reason: changed onbeforeunload typo

  2. #2
    Sencha - Services Team hendricd's Avatar
    Join Date
    Aug 2007
    Location
    Long Island, NY USA
    Posts
    5,966
    Vote Rating
    15
      0  

    Default

    Code:
    Ext.EventManager.on(window, 'onbeforeunload', this.onBeforeUnload, this);
    "be dom-ready..."
    Doug Hendricks

    Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.


    Got Sencha licensing questions? Find out more here.


  3. #3
    Sencha - Community Support Team mankz's Avatar
    Join Date
    Nov 2007
    Location
    Stockholm, Sweden
    Posts
    3,015
    Vote Rating
    182
      0  

    Default

    That was just a typo in the forum post sorry, I use the code you wrote. Still doesn't work.

  4. #4
    Sencha User
    Join Date
    May 2012
    Posts
    49
    Vote Rating
    0
      0  

    Default

    I am facing the same issue.

  5. #5
    Sencha User
    Join Date
    Apr 2012
    Posts
    79
    Vote Rating
    3
      0  

    Default

    Hi,
    I have the issue like i want to show my own message and button names but it is displaying the default message which i dont want. Can anybody help me what i need to do?




    Thanks
    Url

  6. #6
    Sencha User
    Join Date
    Aug 2013
    Posts
    35
    Vote Rating
    0
      0  

    Default Whats event to find if the maximise button was clicked on the browser

    Just like this works do we have an event that detects if the maximize button was clicked ion the browser
    Ext.EventManager.on(window, 'beforeunload', function () {
    alert('cross-exit tab click AND cross-exit browser click');
    });

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •