2013-07-01 49 views

回答

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在注释中说,加入meaninful代码到你的答案,以便其他人可以理解的错误,当他们搜索和查找您的问题编辑答案。

3

您确实需要升级到IE8 +并在IE7模式下运行该页面。原因是,浏览器的调试器会带你正确地处理错误。

在main.js

   }); 

      }, <-- the error is the trailing comma 

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

删除逗号,它应该工作。

有一个致力于此错误的网站:http://trailingcomma.com/

+0

好,thx很多:) – nuffsaid

+1

我希望我知道像永远以前那样的页面。< –

+0

哈哈我已经从来没有见过这个网站,那真棒。我遇到的唯一问题是数组中尾随的逗号不是错误,尤其不是IE所特有的 – Ian

相关问题