firefox 兼容 event.stopPropagation() 阻止冒泡。
2017-09-15 22:50
399 查看
x
转载地址:我是转载地址^>_<^
x
转载地址:我是转载地址^>_<^
解决方案一:
<input onclick='X(event)' .../> //将event作为一个参数,传递过来.... function X(event){ event.stopPropagation(); }
解决方案二:
//得到事件 function getEvent(){ if(window.event) {return window.event;} func=getEvent.caller; while(func!=null){ var arg0=func.arguments[0]; if(arg0){ if((arg0.constructor==Event || arg0.constructor ==MouseEvent || arg0.constructor==KeyboardEvent) ||(typeof(arg0)=="object" && arg0.preventDefault && arg0.stopPropagation)){ return arg0; } } func=func.caller; } return null; } //阻止冒泡 function cancelBubble() { var e=getEvent(); if(window.event){ //e.returnValue=false;//阻止自身行为 e.cancelBubble=true;//阻止冒泡 }else if(e.preventDefault){ //e.preventDefault();//阻止自身行为 e.stopPropagation();//阻止冒泡 } }
x
相关文章推荐
- click点击一次触发多次,冒泡与阻止冒泡,event.stopPropagation()和event.preventDefault(),return false三种的区别
- s事件之event.preventDefault()与event.stopPropagation()的阻止默认事件和阻止事件冒泡的用法
- 阻止冒泡的方法 event.stopPropagation();
- js阻止时间冒泡事件——event.stopPropagation()
- Jquery阻止事件冒泡 event.stopPropagation
- jquery阻止冒泡事件:$('span').bind("click",function(event){event.stopPropagation();})(有用源)
- 阻止事件冒泡,阻止默认事件,event.stopPropagation()和event.preventDefault(),return false的区别
- jquery的冒泡事件event.stopPropagation()兼容问题
- s事件之event.preventDefault()与event.stopPropagation()的阻止默认事件和阻止事件冒泡的用法
- jquery阻止冒泡事件:$('span').bind("click",function(event){event.stopPropagation();})(有用源)
- 实例 (用到 阻止事件冒泡 event.stopPropagation();)
- 兼容firefox,ie,谷歌,阻止浏览器冒泡事件,Firefox不支持event解决方法
- Jquery阻止事件冒泡 event.stopPropagation
- AngularJS阻止事件冒泡$event.stopPropagation()
- 阻止默认和冒泡事件,认清event.preventDefault()、event.stopPropagation()和return false区别
- 事件冒泡阻止event.stopPropagation()
- 阻止事件冒泡event.stopPropagation()
- jquery阻止冒泡事件:$('span').bind("click",function(event){event.stopPropagation();})(有用源)
- 停止冒泡和阻止浏览器默认行为stopPropagation preventDefault
- js中的event.preventDefault()和event.stopPropagation()用法及兼容