List all object IDs in a form

How would i get a list of all object IDs on a page/form?

cheers

monkey

Sorry, I mean the ID of all elements not objects - as in the ID of all the form fields on the page.

cheers

What do you mean by ‘object IDs’?

This will display the id attribute values of all <object> tags on a page:

var objs = document.getElementsByTagName("object");
for (var i = 0; i < objs.length; ++i) {
    alert(objs[i].id);
}

Okay, just replace “object” with “*” then. You may want to filter out all the elements that don’t have an ID:

var objs = document.getElementsByTagName("*");
for (var i = 0; i < objs.length; ++i) {
    if (objs[i].id) {
        alert(objs[i].id);
    }
}