18. apr. 2006

Javascript: Show all properties for an object

I would like to see all the properties of a given object.

OK - Here you go:
     function popUpProperties(inobj) {
op = window.open();
op.document.open('text/plain');
for (objprop in inobj) {
op.document.write(objprop + ' => ' + inobj[objprop] + '\n');
}
op.document.close();
}
Ex.:
popUpProperties(document.forms[0]);

Nice...

Ingen kommentarer: