日期:2014-05-16  浏览次数:20315 次

阻止冒泡小问题

function stopPropagation(){
var e = arguments.callee.caller.arguments[0]  || window.event;
if(e.stopPropagation){
e.stopPropagation();
}else{
e.cancelBubble = true;
}
}

定义一个阻止冒泡的方法,在
showFavorite.prototype = {
showLevelOne: function(){
stopPropagation();
if($('#menu').css('display') == 'block'){
$('#menu').animate({width: "0", height: this.constractHeight, opacity: '0'}, 300, this.allHide);
}else{
createMask();
$('#menu').show().animate({width: this.menuWidth, height: this.menuHeight, opacity:'1'},300);
menuTop = $("#menu").offset().top;
}

这个方法中调用火狐下报e is undefined 错误,求助这是什么问题
javascript

------解决方案--------------------
LZ,firefox里没有window.event对象,如果需要event对象,可以通过参数方式传递

function?stopPropagation(event){
????????//var?e?=?arguments.callee.caller.arguments[0]??
------解决方案--------------------
?window.event;
        e = event 
------解决方案--------------------
 arguments.callee.caller.arguments[0] 
------解决方案--------------------
 window.event;
????????if(e.stopPropagation){
????????????e.stopPropagation();
????????}else{
????????????e.cancelBubble?=?true;
????????}
????}


showFavorite.prototype = {
        showLevelOne: function(e){
            stopPropagation(e);
            if($('#menu').css('display') == 'block'){
                $('#menu').animate({width: "0", height: this.constractHeight, opacity: '0'}, 300, this.allHide);
            }else{