Skip to content

Instantly share code, notes, and snippets.

@rocktronica
Created August 11, 2012 21:26
Show Gist options
  • Save rocktronica/3327415 to your computer and use it in GitHub Desktop.
Save rocktronica/3327415 to your computer and use it in GitHub Desktop.
Fake console for iPads, etc
(function(){
document.body.innerHTML += '<pre id="preConsole" style="position: absolute; left: 10px; top:10px; height: 200px; width: 400px; background-color: rgba(0,0,0,.9); *background: #000; color: #fff; z-index: 1000; padding: 10px; overflow: auto; font: 12px/15px Monospace; margin: 0;"></pre>';
var pre = document.getElementById("preConsole");
window.console = {
log: function() {
var a=[], iCount=arguments.length;
for (var i=0; i<iCount; i++) { a.push(typeof arguments[i] === "object" ? JSON.stringify(arguments[i]) : arguments[i].toString()); }
pre.innerHTML += a.join(', ') + '\n';
}
};
window.onerror = function() { window.console.log("ERROR:", arguments); };
}());
@rocktronica
Copy link
Author

took out the condition checks, since you shouldn't be putting this live anywhere. background hack for ie6/7.

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