views:

46

answers:

2

I'd like to modify the default behavior of my browser when drag&drop-ing a file in my webapp (html5). By default, if you drop a file outside a dropable box the browser tries to open it and quit the current page.

On gmail, this is desactivated! Have you got an idea how this is done ?

I was thinking about the onbeforeunload event but it creates an alert so it's not the solution.

(I'm using plupload)

A: 

I think you're on the right track with onbeforeunload, however you might want to disable the alert with a preventdefaultbehavior. Let me know how that works...

Sorry this didn't work! Firefox and chrome ignore preventDefault() for this event. I found a solution which is quite ugly: when the uploader appears I add the three native events : dragover, dragenter and drop to every div containers.
Tug
A: 

You should make the whole page expect a file drop and not accept it.

Nickolay