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

解决方案 »

  1.   

    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{
                    createMask();
                    $('#menu').show().animate({width: this.menuWidth, height: this.menuHeight, opacity:'1'},300);
                    menuTop = $("#menu").offset().top;
                }