jQuery、IE、无效参数

发布于 2024-09-12 01:22:38 字数 2072 浏览 3 评论 0原文

我用 jQuery 编写了一个简单的滑动画廊。它是一个狭窄的容器,内部有一个宽表格,可以通过 .animate() 更改其“left”属性,

在 Firefox、Safari 和 IE8 上运行良好。但是我在使用 Internet Explorer 7 及更低版本时遇到问题。

弹出一条错误消息,提示“脚本错误”。行:4619。字符:4。错误:参数无效。网址:http://www.imagina.com.uy/bentancorleborgne/?page_id= 2

该行只能位于 jQuery.js 文件内。因为它是唯一一个超过 6k 行的文件。

所以我想知道。到底是怎么回事!!

仅当我按箭头对图库进行动画处理时,才会弹出该错误。所以我留下了脚本的代码,以防万一您可以从那里得到一些线索。

任何帮助或线索将不胜感激。提前致谢!!

$(document).ready(function() {      
    var tablaWidth = parseFloat($('.imagenesWrapper table').width());
    var tdWidth = parseFloat( $('.imagenesWrapper table tr td').outerWidth() )  +  parseFloat( $('.imagenesWrapper table tr td').css('marginRight') );
    var cantCeldas = tablaWidth / tdWidth - 1;
    var posActual = 0;
    var leftCSS = 1;

    if(cantCeldas==0) {
        $('#leftArrow').hide();
        $('#rightArrow').hide();
    }
    else 
        $('#rightArrow').show();


    $('#rightArrow').click(function() {
        if(leftCSS < tablaWidth) {
            posActual += 1;
            leftCSS = moverTabla(posActual, cantCeldas, tdWidth);
        }
    });
    $('#leftArrow').click(function() {
        if(posActual > 0) {
            posActual -= 1;
            leftCSS = moverTabla(posActual, cantCeldas, tdWidth);
        }
    }); 
});

function moverTabla(pos, cantidad, tdWidth) {   
    var leftCSS = pos * tdWidth;
    $('.imagenesWrapper table').animate( {left: '-' + leftCSS +'px'}, 'slow');      
    mostrarOcultarFlechas(pos, cantidad);       
    return leftCSS;
}

function mostrarOcultarFlechas(pos, cantidad) { 
    //mostrar-ocultar flecha izquierda
    if(pos==0) 
        $('#leftArrow').hide();
    else if($('#leftArrow').css('display') == 'none') 
        $('#leftArrow').show(); 
    //mostrar-ocultar flecha derecha    
    if(pos==cantidad) 
        $('#rightArrow').hide();
    else if($('#rightArrow').css('display') == 'none') 
        $('#rightArrow').show();
}

I coded a simple sliding gallery with jQuery. It's a narrow container with a wide table inside that changes it's 'left' property through .animate()

Works beautifully on Firefox, Safari and IE8. However i'm having an issue with internet explorer 7 and below.

A message error pops up saying 'script error. line: 4619. char: 4. error: invalid argument. url: http://www.imagina.com.uy/bentancorleborgne/?page_id=2

That line can only be inside the jQuery.js file. Since it's the only file with 6k+ lines.

So I'm wondering. What the hell is going on!!

The error only pops up when I press the arrow to animate the gallery. So I'm leaving the script's code just in case you can get some clue from there.

Any help or clue would be geatly appreaciated. Thanks in advance!!

$(document).ready(function() {      
    var tablaWidth = parseFloat($('.imagenesWrapper table').width());
    var tdWidth = parseFloat( $('.imagenesWrapper table tr td').outerWidth() )  +  parseFloat( $('.imagenesWrapper table tr td').css('marginRight') );
    var cantCeldas = tablaWidth / tdWidth - 1;
    var posActual = 0;
    var leftCSS = 1;

    if(cantCeldas==0) {
        $('#leftArrow').hide();
        $('#rightArrow').hide();
    }
    else 
        $('#rightArrow').show();


    $('#rightArrow').click(function() {
        if(leftCSS < tablaWidth) {
            posActual += 1;
            leftCSS = moverTabla(posActual, cantCeldas, tdWidth);
        }
    });
    $('#leftArrow').click(function() {
        if(posActual > 0) {
            posActual -= 1;
            leftCSS = moverTabla(posActual, cantCeldas, tdWidth);
        }
    }); 
});

function moverTabla(pos, cantidad, tdWidth) {   
    var leftCSS = pos * tdWidth;
    $('.imagenesWrapper table').animate( {left: '-' + leftCSS +'px'}, 'slow');      
    mostrarOcultarFlechas(pos, cantidad);       
    return leftCSS;
}

function mostrarOcultarFlechas(pos, cantidad) { 
    //mostrar-ocultar flecha izquierda
    if(pos==0) 
        $('#leftArrow').hide();
    else if($('#leftArrow').css('display') == 'none') 
        $('#leftArrow').show(); 
    //mostrar-ocultar flecha derecha    
    if(pos==cantidad) 
        $('#rightArrow').hide();
    else if($('#rightArrow').css('display') == 'none') 
        $('#rightArrow').show();
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

仅此而已 2024-09-19 01:22:38

问题是 IE7-$('.imagenesWrapper table tr td').css('marginRight' 返回 auto )

因此,parseFloat() 返回 NAN不是数字),之后一切都会失败......

检查原因。 。

The problem is that IE7- returns auto for the $('.imagenesWrapper table tr td').css('marginRight')

So the parseFloat() returns NAN (not a number) and everything fails after that..

checking for the reason ..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文