首页 > 代码库 > JavaScript停止冒泡和阻止浏览器默认行为

JavaScript停止冒泡和阻止浏览器默认行为

JS停止冒泡

function myfn(e){  window.event? window.event.cancelBubble = true : e.stopPropagation();}

js阻止默认行为

function myfn(e){  window.event? window.event.returnValue = http://www.mamicode.com/false : e.preventDefault();}

 

 

原文:

http://caibaojian.com/javascript-stoppropagation-preventdefault.html

JavaScript停止冒泡和阻止浏览器默认行为