我從How to get mouseup to fire once mousemove complete得到了這個腳本,它在jQuery(document)範圍內工作。flash對象沒有觸發的Mouseup事件
後來我在主體內添加了一個flash對象。當我點擊flash對象時,mousedown事件觸發,mousemove事件觸發,但不是mouseup事件,我想要解除鼠標移動。
但是,當我點擊非Flash區域,mousedown的作品,mousemove的作品,並且mouseup也適用。它的工作方式就像我想在Chrome中使用它,但不在Firefox中。
這裏是代碼,我在$(document).ready
handleMouseDown: function() {
jQuery(document).mouseup(function() {
Log("unbind.");
jQuery(document).unbind('mousemove');
});
jQuery(document).mousedown(function(e) {
Log('click');
// You can record the starting position with
var start_x = e.pageX;
var start_y = e.pageY;
jQuery(document).mousemove(function(e) {
// And you can get the distance moved by
var offset_x = e.pageX - start_x;
var offset_y = e.pageY - start_y;
Log('moves') ;
return false;
});
// Using return false prevents browser's default,
// often unwanted mousemove actions (drag & drop)
return false;
});
}
//firebug method log calls
function Log(str) {
if (typeof(console.log) == 'function') console.log(str);
}
它就像我在Chrome它想。但不是在Firefox中。 – r4ccoon 2011-04-08 03:57:57