//方案1: 很差的寫法 function processEvent(e){ e = arguments.callee.caller.arguments[0] || e; if(e && e.stopPropagation){ e.stopPropagation(); }else if(window.event){ window.event.cancelBubble = true; } if(e && e.preventDefault){ e.preventDefault(); }else if(window.event){ window.event.returnValue = false; } } // 方案2:建議使用此方案 // 阻止冒泡 function processBubble(e){ e = arguments.callee.caller.arguments[0] || e; if(e && e.stopPropagation){ e.stopPropagation(); }else if(window.event){ window.event.cancelBubble = true; } } // 阻止瀏覽器默認行爲 function processDefault(e){ e = arguments.callee.caller.arguments[0] || e; if(e && e.preventDefault){ e.preventDefault(); }else if(window.event){ window.event.returnValue = false; } } // 阻止冒泡和默認行爲 function processBubbleAndDefault(e){ processBubble(e); processDefault(e); }