How do we prevent default actions in JavaScript?

前端 未结 3 1902
情深已故
情深已故 2020-12-11 10:11

What is the cross-browser method? I need to prevent any default action on an image, so that neither dragging nor anything else will fire on a default bases.

3条回答
  •  北海茫月
    2020-12-11 10:24

    You can only cancel specific events. You cannot "globally cancel" default actions.

    To specifically cancel dragging an image (which is only a default function in some browsers), return false to the mousedown event.

提交回复
热议问题