IE瀏覽器監聽:瀏覽器
function attachEvent(string eventFlag, function eventFunc)
eventFlag: 事件名稱,但要加上on,如onclick、onmouseover…
eventFunc: 綁定到事件中執行的動做
在事件監聽流中能夠使用window.event.cacenlBubble=false來阻止事件繼續往下流seo
非IE瀏覽器監聽:事件
function addEventListener(string eventFlag, function eventFunc, [bool useCapture=false])
eventFlag : 事件名稱,如click、mouseover…
eventFunc: 綁定到事件中執行的動做
useCapture: 指定是否綁定在捕獲階段,true爲是捕獲階段,false爲冒泡階段,默認爲true
在事件監聽流中能夠使用event.stopPropagation()來阻止事件繼續往下流string
防止冒泡:io
var stopEvent = function(event){ e = event || window.event; if(e.stopPropagation){ e.stopPropagation(); }else { e.cancelBubble = true; } };event