I would like to be able to use javascript to find every id (or name) for every object in an html document so that they can be printed at the bottom of the page.
To under
First of all, I would highly recommend jQuery. It has simplified my JavaScript development soooo much. (See RichieHindle's answer)
Second, I know that a lot of browsers keep a list of IDs for direct (fast) access, but I don't know of a way to access them. It would probably be browser-specific anyways, so that's probably not the best route.
Finally, the code:
var elementList = document.getElementsByTagName("*");
var idList = [];
for (var i in elementList) {
if (elementList[i].id != "") {
idList.push(elementList[i].id);
}
}
// Do something with your array of ids