锁定鼠标事件
setCapture只可以作用于以下事件
- onclick
- ondblclick
- onmousedown
- onmouseup
- onmouseover
- onmouseout
- 当参数是ture时 ,当前元素会捕获其内的所有子元素的鼠标事件
- 当参数为false时,当前元素不会捕获该其内的所有子元素的鼠标事件 ,容器内的对象能够正常地触发事件和取消冒泡
document.getElementsByTagName('img')[0].οnmοusedοwn=function(){
this.setCapture(true);
}
禁止图片默认事件
document.getElementsByTagName('img')[0].onmousedown = function(e){
e.preventDefault()
};
禁止拖拽
<img src="#" draggable="false">
// 禁止选中
document.onmousemove = function (ev) {
window.getSelection ? window.getSelection().removeAllRanges() : document.selection.empty();
}
https://blog.csdn.net/icebns/article/details/102521332 图片拖拽效果
https://blog.csdn.net/diwuyanting/article/details/78270751 禁止图片默认事件
https://blog.csdn.net/suzhenzhen/article/details/76082879 锁定鼠标事件
https://blog.csdn.net/wangkunroy/article/details/72884786 锁定和解锁