Is there a way to enumerate all attributes associated with an image, or for that matter the attributes associated with any other element in a web page? I know I can access attributes if I specify them, eg. the source of an image as document.images.src, or the width as document.images.width, but what if I want to list every attribute? Have attached a little code below where I loop through every image in a page, and identify each of four attributes. But rather than explicitly naming the attributes I want (which in some cases finds attributes undefined, like useMap for image 2), is there a way to write an inner loop, from attribute = 0 to (number of defined attributes), similar to the way the outer loop is from 0 to (number of images)? That way the code could generically be applied to any object, without naming the specific attributes.
<title>Enumerate Image Attributes</title>
<img src="image1.jpg" usemap="#Map1" name="Image1" width="400" height="240" border="0" id="Image1" />
<img src="image2.jpg" name="Image2" width="200" height="120" border="0" id="Image2" />
alert("image "+ i + " source is "+document.images[i].src);
alert("image "+ i + " id is "+document.images[i].id);
alert("image "+ i + " width is "+document.images[i].width);
alert("image "+ i + " map is "+document.images[i].useMap);