Mozilla Firefox和函数执行时出现问题。

| 大家好,我对此代码有疑问。当我在IExplorer 9,Chrome 12.0.742.30 dev和Opera 11.10下尝试代码时,代码可以正常运行,但在Firefox 3和4代下,代码运行缓慢。我的意思是,当我在第三张图片上并且图片尺寸为400x400px并按\“ previous \” / \“ next \”时,函数updateLightBox()必须使用第二张图片的大小来调整容器的大小,但是没有。第二张图片的尺寸为200x200px,但是下次我按\“ previous \” / \“ next \”时,容器将获得此尺寸,但是第一张图片的尺寸不同,并且该图片不在显示中心,并且按钮不在其位置上。
$(\'div#next\').unbind().bind(\'click\', function() {
    if(currentImage == arrayLength-1) {
        var Image = 0;
    }
    else {
        var Image = currentImage+1;
    }
    $(\'img#image\').attr(\'src\', imageArray[Image]);
    updateLightBox();
    cfg.activeImage = Image;
    currentImage = Image;
});
$(\'div#prev\').unbind().bind(\'click\', function() {
    if(currentImage == 0) {
        var Image = arrayLength-1;
    }
    else {
        var Image = currentImage-1;
    }
    $(\'img#image\').attr(\'src\', imageArray[Image]);
    updateLightBox();
    cfg.activeImage = Image;
    currentImage = Image;
});
函数updateLightBox()是:
function updateLightBox() {
    var imgWidth = $(\'img#image\').width();
    var imgHeight = $(\'img#image\').height();
    var top = (height - imgHeight) / 2;
    var left = (width - imgWidth) / 2;

    $(\'div#imgAlt\').remove();
    $(\'span#imgNum\').remove();
    $(\'div#alt\').append(\'<div id=\"imgAlt\">\'+altArray[cfg.activeImage]+\'</div>\');
    $(\'div#alt\').append(\'<span id=\"imgNum\">\'+(cfg.activeImage+1)+\' / \'+arrayLength+\'</span>\');
    $(\'img#image\').attr(\'alt\', altArray[cfg.activeImage]);

    $(\'div#lightbox\').animate({
        \'top\': top,
        \'left\': left,
        \'width\': imgWidth+\'px\',
        \'max-width\': imgWidth+\'px\',
        \'min-width\': cfg.minContainerWidth+\'px\',
        \'height\': imgHeight+\'px\',
        \'max-height\': imgHeight+\'px\',
        \'min-height\': cfg.minContainerHeight+\'px\'
    }, cfg.containerResizeSpeed);

    $(\'div#image\').animate({
        \'position\': \'absolute\',
        \'margin\': 0,
        \'padding\': 0,
        \'zIndex\': 902,
    }, cfg.containerResizeSpeed);

    $(\'div#alt\').animate({ 
        \'width\': imgWidth-20+\'px\',
    }, cfg.containerResizeSpeed);

    $(\'div#prev\').animate({
        \'top\': (imgHeight / 2) - 16+\'px\',
    }, cfg.containerResizeSpeed);

    $(\'div#next\').animate({
        \'top\': (imgHeight / 2) - 16+\'px\',
    }, cfg.containerResizeSpeed);

    $(\'div#imgAlt\').css({
        \'font-family\': \'Times New Roman, Georgia, Serif\',
        \'font-size\': \'14px\',
        \'font-weight\': \'bold\',
        \'color\': cfg.altTextcolor,
    });

    $(\'span#imgNum\').css({
        \'font-family\': \'Times New Roman, Georgia, Serif\',
        \'font-size\': \'11px\',
        \'font-weight\': \'bold\',
    });
}
如果有人知道如何解决并告诉我,我将非常高兴和感激:) 带着敬意, 乔治 :]     
已邀请:
调用更新函数后,设置currentImage
updateLightBox();
cfg.activeImage = Image;
currentImage = Image;
应该
cfg.activeImage = Image;
currentImage = Image;
updateLightBox();
    

要回复问题请先登录注册