拖动的问题,在网上有很多插件,但鼠标在图片上拖动一小段距离,就会在鼠标旁边出现一个禁止的小提示。
解决如果点击在图片上无法拖拽的问题:
IE通过ev.cancelBubble=true;ev.returnValue = false;来防止图片的事件,注意是放在document.onmousemove中。要用原生的JS,不能用JQUERY!
FireFox通过ev.preventDefault();ev.stopPropagation(); 但是是放在titleBar的mousedown事件中。
$(function(){ var $img = $("img"); var moving = function(event){ //something }
//IE下需要在document的mousemove里面取消默认事件;要用原生JS的事件不能用JQuery
document.onmousemove = function(e){ var ev = e || event;
ev.cancelBubble=true;
ev.returnValue = false;
}
$img.mousedown(function(event){ //FF下需要在mousedown取消默认操作; event.preventDefault();
event.stopPropagation();
$(this).bind("mousemove",moving);
})
})