Jslfl【软件开发技术笔记】

兼容低版本IE未定义console

1
2
3
4
5
6
7
8
9
/**
 * 处理低版本IE未定义console
 */

if (!window.console || !console.firebug){
    var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
    window.console = {};
    for (var i = 0; i < names.length; ++i)
        window.console[names[i]] = function() {}
}

, ,

Comments are currently closed.