A JavaScript script only works on Internet Explorer when the Internet Explorer Developer Toolbar is visible

后端 未结 3 2108
被撕碎了的回忆
被撕碎了的回忆 2021-02-18 18:53

I got a script working on Firefox 5 but not with Internet Explorer 9. When I just open the Internet Explorer Developer Toolbar addon and try the same actions as befor

3条回答
  •  感动是毒
    2021-02-18 19:38

    As mentioned in a similar question, use this code (in a script tag at the top of your page before other script tags, preferably):

    (function() {
        var method;
        var noop = function () {};
        var methods = [
            'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error',
            'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log',
            'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd',
            'timeStamp', 'trace', 'warn'
        ];
        var length = methods.length;
        var console = (window.console = window.console || {});
    
        while (length--) {
            method = methods[length];
    
            // Only stub undefined methods.
            if (!console[method]) {
                console[method] = noop;
            }
        }
    }());
    

    or find a more up to date version of this same code here: https://github.com/h5bp/html5-boilerplate/blob/master/src/js/plugins.js

    This just solved that same issue for me.

提交回复
热议问题