
什么是事件,ie与火狐的时间机制有什么区别?如何阻止冒泡
1个回答
展开全部
function stopEvent(){ //阻止冒泡事件
//取消事件冒泡
var e=arguments.callee.caller.arguments[0]||event; //若省略此句,下面的e改为event,IE运行可以,但是其他浏览器就不兼容
if (e && e.stopPropagation) {
// this code is for Mozilla and Opera
e.stopPropagation();
} else if (window.event) {
// this code is for IE
window.event.cancelBubble = true;
}
}
一般在IE环境下可以省略掉(var e=arguments.callee.caller.arguments[0]||event;)直接运行即可,但是在FF下不行了,它会报e.stopPropagation没有定义,所以要事先定义,才能兼容。
//取消事件冒泡
var e=arguments.callee.caller.arguments[0]||event; //若省略此句,下面的e改为event,IE运行可以,但是其他浏览器就不兼容
if (e && e.stopPropagation) {
// this code is for Mozilla and Opera
e.stopPropagation();
} else if (window.event) {
// this code is for IE
window.event.cancelBubble = true;
}
}
一般在IE环境下可以省略掉(var e=arguments.callee.caller.arguments[0]||event;)直接运行即可,但是在FF下不行了,它会报e.stopPropagation没有定义,所以要事先定义,才能兼容。
本回答被提问者和网友采纳

你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询