Monday, September 22, 2008

Use javascript to prevent firefox from loading stuff into your page

So say you have a cool Photo web application. It's so cool that people think that they can just drag photos from their desktop to anywhere on the page and it'll get uploaded, NOT.

Well at least not yet.

What happens is that firefox loads up the image totally replacing your page. To avoid that, add this line of code at the head of your html page and you should be all set.

window.addEventListener('dragdrop', function(event) { event.stopPropagation() }, false)