我在IE7中收到一个Script Error弹出窗口(预期的标识符,字符串或数字)

时间:2013-07-01 17:24:07

标签: javascript jquery

我在IE7中遇到错误,无法确定导致它的原因是什么?

错误如下: enter image description here

请在此处查看网站:http://www.wearewebstars.dk/frontend/Elevunivers/index.html

2 个答案:

答案 0 :(得分:3)

您确实需要升级到IE8 +并以IE7模式运行该页面。原因是,浏览器的调试器会直接指向错误。

在main.js

                });

            },  <-- the error is the trailing comma

        }
    }
    // Initialize main script-Engine;
    Engine.init();
});

删除逗号,它应该有效。

有一个专门针对此错误的网站:http://trailingcomma.com/

答案 1 :(得分:0)

IE在最后一个对象之后有逗号(请参阅注释行)时抛出错误。 阅读更多this answer in stackoverflow

ui: {

        tabs: function() {

            $(".tabs-content div.tabpage").hide(); // Initially hide all content
            $(".tabs li:first").attr("id","current"); // Activate first tab
            $(".tabs-content div:first").fadeIn(); // Show first tab content

            $('.tabs a').click(function(e) {
                e.preventDefault();
                var className = $(this).attr("name")
                $(document).find(".tab-container").attr("class","grid_9 tab-container "+className);

                if ($(this).closest("li").attr("id") == "current"){ //detection for current tab
                 return       
                }
                else{             
                $(".tabs-content div.tabpage").hide(); //Hide all content
                $(".tabs li").attr("id",""); //Reset id's
                $(this).parent().attr("id","current"); // Activate this
                $('#' + $(this).attr('name')).fadeIn(); // Show content for current tab
                }
            });

        }, // <---------- THIS COMMA

    }

如果你有IE8 +,你可以按F12带开发者工具并检查控制台选项卡: enter image description here

单击该错误会转到指向该行所在的脚本(如此)。 enter image description here

<强> P.S: 除此之外,根据@ j08691在评论中所说的内容编辑你的答案,在你的答案中添加有意义的代码,以便其他人在搜索并找到你的问题时能够理解错误。