Chrome browser has this weird functionality that when I drag a div, or image, it drags that item. For example, if you go to you'll be able to drag that google image.
The thing is, it's messing with my javascript events. Is there a way, in javascript to disable this functionality for the chrome/safari browser?
Chrome browser has this weird functionality that when I drag a div, or image, it drags that item. For example, if you go to http://www.google.com you'll be able to drag that google image.
The thing is, it's messing with my javascript events. Is there a way, in javascript to disable this functionality for the chrome/safari browser?
Share Improve this question asked Mar 19, 2012 at 18:52 Shai UIShai UI 51.9k77 gold badges217 silver badges316 bronze badges 1- Does this help -- stackoverflow.com/questions/704564/… – Dan U. Commented Mar 19, 2012 at 18:56
3 Answers
Reset to default 12The other answers suggesting .preventDefault()
do not work for me in Chrome (v26). Had to set draggable='false'
HTML5 attribute on the image. FWIW I'm using the threedubmedia drag jQuery plugin (actually the nifty newer jdragdrop reimplementation).
Calling
event.preventDefault();
in your event handler should disable that.
Reference
I had the same problem when I needed to create my own drag and drop functionality. I was using mousedown, mouseup, and mousemove events. I solved it by adding event.preventDefault();
as the first line in my mousedown event handler.