Last active
September 15, 2015 14:44
-
-
Save apa6ec/c0d5c8216ef46244b5c9 to your computer and use it in GitHub Desktop.
Handle non-console supporting browsers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Handle non-console supporting browsers | |
(function () { | |
if (!window.console) { | |
window.console = {}; | |
} | |
// union of Chrome, FF, IE, and Safari console methods | |
var m = [ | |
'log', 'info', 'warn', 'error', 'debug', 'trace', 'dir', 'group', | |
'groupCollapsed', 'groupEnd', 'time', 'timeEnd', 'profile', 'profileEnd', | |
'dirxml', 'assert', 'count', 'markTimeline', 'timeStamp', 'clear' | |
]; | |
// define undefined methods as noops to prevent errors | |
for (var i = 0; i < m.length; i++) { | |
if (!window.console[m[i]]) { | |
window.console[m[i]] = function() {}; | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment