0
基本上我希望能夠從FireBug調用jQuery,將代碼監聽頁面上的所有事件觸發,然後顯示有關事件觸發的信息,而無需瞭解頁面結構或事件類型的任何信息具有。jQuery事件監聽
var s = document.createElement('script');
s.setAttribute('src', 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js');
document.body.appendChild(s);
s.onload=function(){
// Bind a listening event without overwriting the original events
/* jQuery("*").[something](function(){
console.log (jQuery(this));
});*/
}
可能的解決方案:
*我想通過每一個元素去創造和保存爲對象的事件元素的原始事件,但是我希望會有一個更簡單的方法。
*如果存在一種偵聽從對象觸發的事件而不覆蓋當前事件綁定的方法,那將是更可取的。作爲jimbojw提到,所謂event.stopPropagation不會被捕獲的事件 :因爲所有事件使用冒泡階段該文件將趕上他們, http://www.quirksmode.org/js/events_order.html
編輯
var arrEvent = ['blur','focus','focusin','focusout','load','resize','scroll','unload','click','dblclick','mousedown','mouseup','mousemove','mouseover','mouseout','mouseenter','mouseleave','change','select','submit','keydown','keypress','keyup','error'];
$(document).bind(arrEvent.join(' '), function(e){
// play with e
});
:
只要沒有處理程序調用stopPropagation(),即:/ – jimbojw 2011-05-13 21:04:21
您的代碼工作得體,糟糕的代碼捕獲螢火蟲中的事件以及我感興趣的頁面中的事件。 – dunpealslyr 2011-09-09 23:55:30