0

I would like to disable the option to drag and drop files to a webpage in IE 8. Currently the behavior is that IE 8 tries to open the file.

I am using JQuery and this code:

$(document).ready(function() {
    $('body').on('drop dragover', function(e) {
        e.preventDefault(); // for everything else - this works but not for IE 8
        e.returnValue = false; // for IE 8 - but this does not work
    });
});

update:

$(document).on('drop dragover', function(e) {
            if(e.preventDefault){
                e.preventDefault(); // for everything else - this works but not for IE 8
            }
            else{
                e.returnValue = false; // for IE 8 - but this does not work
            }

jsfiddle for Chrome to prove this works: https://jsfiddle.net/07qgw36b/

1 Answers1

0

Try the following:

(event.preventDefault) ? event.preventDefault() : event.returnValue = false;

Maybe it is not getting the the event.returnValue line because e.preventDefault() comes back undefined.

PreventDefault alternative for IE8

Community
  • 1
  • 1
apandit
  • 808
  • 1
  • 7
  • 16