最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to disable dragdrop functionality in Chrome? - Stack Overflow

programmeradmin4浏览0评论

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
Add a comment  | 

3 Answers 3

Reset to default 12

The 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.

发布评论

评论列表(0)

  1. 暂无评论