Skip to content

Instantly share code, notes, and snippets.

@damienvancouver
Last active August 29, 2015 14:22
Show Gist options
  • Save damienvancouver/d981a6175a47261153e6 to your computer and use it in GitHub Desktop.
Save damienvancouver/d981a6175a47261153e6 to your computer and use it in GitHub Desktop.
ie console log shiv thing
<script type="text/javascript">
<?php /*
* 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
* @see http://stackoverflow.com/a/13817235/888986
*/ ?>
(function() {
if (!window.console) {
window.console = {};
}
var m = [
"log", "info", "warn", "error", "debug", "trace", "dir", "group",
"groupCollapsed", "groupEnd", "time", "timeEnd", "profile", "profileEnd",
"dirxml", "assert", "count", "markTimeline", "timeStamp", "clear"
];
for (var i = 0; i < m.length; i++) {
if (!window.console[m[i]]) {
window.console[m[i]] = function() {};
}
}
})();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment