Created
September 17, 2011 06:44
-
-
Save robert-wallis/1223704 to your computer and use it in GitHub Desktop.
Display the contents of a JavaScript object in the #debug id on the page. Or alert it if there was no debug.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// debug() - Copyright (C) 2006-2008 Robert Wallis | |
function debug(obj, name) | |
{ | |
var t = ""; | |
if (name) { | |
t += ""+name+":"; | |
} | |
for (var i in obj) { | |
t += i+"=\""+obj[i]+"\"\n"; | |
} | |
var d = document.getElementById('debug'); | |
if (d) { | |
d.innerHTML += '<textarea style="font-family: monospace; padding: 8px; background-color:#525252; color:#FF9900;" cols=80 rows=30>'+t+'</textarea>'; | |
} else { | |
alert(t); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment