Created
October 18, 2012 12:13
-
-
Save Simounet/3911421 to your computer and use it in GitHub Desktop.
JS Print_r
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
function print_r(obj) { | |
win_print_r = window.open('about:blank', 'win_print_r'); | |
win_print_r.document.write('<html><body>'); | |
r_print_r(obj, win_print_r); | |
win_print_r.document.write('</body></html>'); | |
} | |
function r_print_r(theObj, win_print_r) { | |
if(theObj.constructor == Array || theObj.constructor == Object){ | |
if (win_print_r == null) | |
win_print_r = window.open('about:blank', 'win_print_r'); | |
} | |
for(var p in theObj){ | |
if(theObj[p].constructor == Array|| theObj[p].constructor == Object){ | |
win_print_r.document.write("<li>["+p+"] =>"+typeof(theObj)+"</li>"); | |
win_print_r.document.write("<ul>") | |
r_print_r(theObj[p], win_print_r); | |
win_print_r.document.write("</ul>") | |
} else { | |
win_print_r.document.write("<li>["+p+"] =>"+theObj[p]+"</li>"); | |
} | |
} | |
win_print_r.document.write("</ul>") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment