【问题标题】:jQuery script only working under ie8/9 developer toolsjQuery 脚本只在 ie8/9 开发者工具下工作
【发布时间】:2011-07-15 21:54:35
【问题描述】:

我正在尝试调试无法在 IE 上运行的 jQuery(Tools) 脚本。可以在这里找到一个例子:

http://dl.dropbox.com/u/16799097/www/demo/jQuery_Slider/index.html

它正确加载,第一个(滑动)事件发生,然后没有附加任何内容。

当我尝试通过使用开发人员工具(按 F12 键)重新加载页面来调试我的脚本时,一切都像一个魅力......如果我无法调试,我该怎么办?

任何帮助将不胜感激,我被卡住了......

【问题讨论】:

    标签: jquery ie-developer-tools


    【解决方案1】:

    错误是(slider.js):

    'console' is undefined
    

    console 对象 is only defined in IE when you open the Developer Tools。然后,不再有 JavaScript 错误,一切正常。

    要解决此问题,您可以删除/注释掉 console.log 调用,或者添加类似这样的内容作为您的第一个 JavaScript 块:

    // make it safe to use console.log always
    (function(b){function c(){}for(var d="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info, log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),a;a=d.pop();)b[a]=b[a]||c})(window.console=window.console||{});
    

    (sn-p 取自http://html5boilerplate.com/)

    【讨论】:

    • 难以置信,这会破坏 IE Angular 应用程序。这个答案FTW
    猜你喜欢
    • 2011-04-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多