Skip to content

Instantly share code, notes, and snippets.

@rutger1140
Created January 11, 2012 09:58
Show Gist options
  • Save rutger1140/1593976 to your computer and use it in GitHub Desktop.
Save rutger1140/1593976 to your computer and use it in GitHub Desktop.
Faux Console for IE, by Chris Heilmann
/* Faux Console by Chris Heilmann http://wait-till-i.com */
if (!window.console) {
var console = {init: function() {
console.d = document.createElement('div');
document.body.appendChild(console.d);
var a = document.createElement('a');
a.href = 'javascript:console.hide()';
a.innerHTML = 'close';
console.d.appendChild(a);
var a = document.createElement('a');
a.href = 'javascript:console.clear();';
a.innerHTML = 'clear';
console.d.appendChild(a);
var id = 'fauxconsole';
if (!document.getElementById(id)) {
console.d.id = id;
}
console.hide();
},hide: function() {
console.d.style.display = 'none';
},show: function() {
console.d.style.display = 'block';
},log: function(o) {
console.d.innerHTML += '<br/>' + o;
console.show();
},clear: function() {
console.d.parentNode.removeChild(console.d);
console.init();
console.show();
}, /*Simon Willison rules*/addLoadEvent: function(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
;
}};
console.addLoadEvent(console.init);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment