标签:兼容性问题 highlight can dev stop document def ati 默认
什么是默认行为?
var a = document.getElementById(‘a‘); a.addEventListener(‘click‘,function(e){ e.preventDefault(); },false);
兼容性问题:
function preventDefault(event){ var event = $$.getEvent(event); if(event.preventDefault){ event.preventDefault(); }else{ event.returnValue = false; //微软 } }
什么是阻止冒泡
$$(‘div2‘).addEventListener(‘click‘,function(event){ event.stopPropagation(); },false)
兼容性问题
function stopPropagation(event){ var event = $$.getEvent(event); if(event.stopPropagation){ event.stopPropagation(); }else{ event.cancelBubble = true; } }
标签:兼容性问题 highlight can dev stop document def ati 默认
原文地址:http://www.cnblogs.com/Abner5/p/7533166.html