1. #1
    Sencha - Community Support Team mankz's Avatar
    Join Date
    Nov 2007
    Location
    Stockholm, Sweden
    Posts
    2,748
    Vote Rating
    106
    mankz is a name known to all mankz is a name known to all mankz is a name known to all mankz is a name known to all mankz is a name known to all mankz is a name known to all

      0  

    Default window.onbeforeunload

    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 - Community Support Team hendricd's Avatar
    Join Date
    Aug 2007
    Location
    Long Island, NY USA
    Posts
    5,962
    Vote Rating
    10
    hendricd will become famous soon enough hendricd will become famous soon enough

      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
    2,748
    Vote Rating
    106
    mankz is a name known to all mankz is a name known to all mankz is a name known to all mankz is a name known to all mankz is a name known to all mankz is a name known to all

      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
    anmol is on a distinguished road

      0  

    Default


    I am facing the same issue.

  5. #5
    Sencha User
    Join Date
    Apr 2012
    Posts
    74
    Vote Rating
    2
    url is on a distinguished road

      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
    34
    Vote Rating
    0
    rajuarien is on a distinguished road

      0  

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

    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');
    });