4

When dragging and dropping files to Internet Explorer and Chrome, they both open the file that was dragged and dropped. I would like to disable this functionality so that the dragged and dropped file does not automatically open.

Is this a browser setting or a Windows setting?

6
  • 1
    What do you want it to do instead?
    – user201262
    Commented Sep 23, 2013 at 23:27
  • 1
    We have a web app that has a drop area and we want the files to upload without opening.
    – David
    Commented Sep 23, 2013 at 23:48
  • what's really strange is that dragging and dropping the file to Chrome doesn't open the file for 99% of our users (there's only a few that Chrome opens the file for). With that said, IE 9 and 10 open the file 100% of the time.
    – David
    Commented Sep 23, 2013 at 23:50
  • This would be an issue with your drag and drop javascript or HTML, rather than an issue with a browser. The file is being opened because the drag and drop code is not triggering. It will still not trigger if you disable file-open in the browser. Best to try to debug the code.
    – Paul
    Commented Sep 24, 2013 at 1:18
  • That's what I was thinking as well Paul but for it to not open for 99% of our chrome users made me think that the issue was elsewhere. And why would it work one way in chrome and another way in IE?
    – David
    Commented Sep 24, 2013 at 1:33

2 Answers 2

1

Answer to the question is both. In browser console:

window.addEventListener("dragover",null)
window.addEventListener("drop",null)

Will disable responds to dragevent within browser and you can turn this into a java bookmarklet. However,

the behaviour is about your operating systems UI and chrome itself. UI sends a message to chrome process that something is dragged over. Chrome responds. You can block either of them as a definite solution.

0

I think this is what you are looking for...

 $( '#div_yourdroparea' ).bind( 'dragover',function(event) {
        event.stopPropagation();    
        event.preventDefault(); 
    });
    $( '#div_yourdroparea' ).bind( 'drop',function(event) {
     event.stopPropagation();   
      event.preventDefault();

    //your upload code goes here....
        }
1
  • 1
    How should this could help at solving the OP's problem?
    – Jens Erat
    Commented Aug 7, 2014 at 6:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .