Skip to content

Instantly share code, notes, and snippets.

@techieshark
Created February 3, 2015 22:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save techieshark/71332a40dd371002ed9f to your computer and use it in GitHub Desktop.
Save techieshark/71332a40dd371002ed9f to your computer and use it in GitHub Desktop.
ie-console.js
/**
* Protect window.console method calls, e.g. console is not defined on IE
* unless dev tools are open, and IE doesn't define console.debug
* http://stackoverflow.com/a/13817235/1024811
*/
(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() {};
}
}
})();
@techieshark
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment