首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

阻止冒泡小疑点

2013-09-12 
阻止冒泡小问题function stopPropagation(){var e arguments.callee.caller.arguments[0]|| window.even

阻止冒泡小问题


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{


                createMask();
                $('#menu').show().animate({width: this.menuWidth, height: this.menuHeight, opacity:'1'},300);
                menuTop = $("#menu").offset().top;
            }

热点排行