Skip to content

Instantly share code, notes, and snippets.

@aaronpowell
Created November 10, 2010 01:19
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 aaronpowell/670180 to your computer and use it in GitHub Desktop.
Save aaronpowell/670180 to your computer and use it in GitHub Desktop.
A basic JavaScript console window for browsers that don't support the console object
if (!window.console) {
window.onload = function() {
var txt = document.createElement('textarea');
txt.style.position = 'absolute';
txt.style.top = '0px';
txt.style.left = '0px';
txt.style.height = '800px';
txt.style.width = '500px';
txt.id = 'console';
document.body.appendChild(txt);
var btn = document.createElement('input');
btn.type = 'button';
btn.value = 'run';
btn.style.position = 'absolute';
btn.style.top = '800px';
btn.style.left = '0px';
btn.style.width = '50px';
btn.onclick = function() {
console.log(eval(txt.value));
};
document.body.appendChild(btn);
};
console = {};
console.log = function(txt) {
var c = document.getElementById('console');
c.value += (txt || '') + '\n';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment