IE中的Javascript错误

时间:2010-12-23 15:43:33

标签: javascript jquery

请帮我纠正javascript中的错误,它在IE中不起作用,我只是无法理解这里有什么问题:

   $(document).ready(function() {
        $(".image2").click(function() {var image = $(this).attr("rel");
        $('#image2').hide();
        $('#image2').fadeIn('slow');
        $('#image2').html('<embed height="253" width="440" wmode="transparent" src="' + image + '"></embed>');
        var image2 = $('#image2 embed').attr('src');
        $("#thumb2 a img").removeClass("open");
        $("#thumb2 a[rel='" + image2 + "'] img").addClass("open");
        return false;
        });
    });
    $(document).ready(function() {  
        var image3 = $('#image2 embed').attr('src');
        $("#thumb2 a[rel='" + image3 + "'] img").addClass("open");

        var n = $('#news_list');    
        n.find('.list_news a').css({opacity: 0.5}).hover(
            function() { $(this).css({opacity: 1}); },
            function() { $(this).css({opacity: 0.7}); }
        );
        n.hover(
            function() { $(this).find('a').css({opacity: 0.7}); },
            function() { $(this).find('a').css({opacity: 0.5}); }
        );
    });

    $(document).ready(function() {  
        $('.image').click(function(event) {
        event.preventDefault();
        var imagePath = $(this).attr("href");
        var newImg = new Image;
        newImg.src = imagePath;
        newImg.onload = function(){
            $('#big_picture').hide();
            $('#big_picture').attr('src', imagePath);
            $('#big_picture').fadeIn('slow');
        };
        });
    });

    $(document).ready(function() {  
        $(".dropdown a").each(function() {
        if(this.href == window.location) 
        $(this).addClass("open");
        });

        $('.slider_fade').cycle({ 
        fx:     'fade',
        timeout: 7000,
        });
    });
    $('.upper_menu_link').attr('target', '_blank');

    var message="";
    function clickIE() {if (document.all) {(message);return false;}}
    function clickNS(e) {if 
    (document.layers||(document.getElementById&&!document.all)) {
    if (e.which==2) {
    (message);
    return false;}}}
    if (document.layers) {
    document.captureEvents(Event.MOUSEDOWN);
    document.onmousedown=clickNS;
    }else{
    document.onmouseup=clickNS;
    document.oncontextmenu=clickIE;
    }
    document.oncontextmenu=new Function("return false");

        $('.urun_div').corner("round 20px");

2 个答案:

答案 0 :(得分:5)

timeout: 7000之后的逗号是问题。

有关Internet Explorer's trailing comma woes的更多信息。

有时候,只要我的代码在IE中失败但在其他浏览器中有效,我就会使用类似于上一个链接的正则表达式搜索我的代码。

此外,Javascript Lint可以为像这样的错误提供大量帮助。

答案 1 :(得分:0)

最近版本的Internet Explorer附带了一组可通过的开发人员工具(通过按F12访问),如果您使用这些工具,他们会告诉您错误发生在哪个行号,错误类型(语法, NaN,未定义等)。

相关问题