1 (edited by enridp 2011-10-12 17:24:05)

Topic: Add files button fires window.onbeforeunload event !!

I'm listening to window.onbeforeunload to alert the user when leaving my form without submit it.

and plupload is firing the event when I click the "add files" button.
This only happens with HTML5 and in Firefox (7).
With HTML5 in Chrome (14) the event is not fired.
I have not tested it in IE+HTML5 (because I don't have IE9 tongue)

@david can you confirm if this is a bug of the plugin or Firefox? and maybe a workaround for it?

Thanks !

EDIT:
more info: I'm using the last version of plupload (1.5.1.1) and I have a drop down for selecting the method (html5, flash, etc), it's automatically by default (with html5 first). And if I select HTML5 explicitly (even when plupload is running HTML5 already) then everything works fine (the window.onbeforeunload is not fired).

this is the code for the select box:

// this creates the plupload queue and return a reference to it
var uploader = createUploader('');

$("#select-upload-runtime").change(function()
        {
            destroyUploader(uploader);
            uploader = createUploader($(this).val());
        });


function destroyUploader(uploader) {
    uploader.destroy();
}

Re: Add files button fires window.onbeforeunload event !!

Well I think I found what was causing the error.
Is the Zend Debugger (which was running only with Firefox), when I close it then it works fine in Firefox too.

Anyway, if someone knows why this happens every explanation is always welcome.