Forum Moderators: open
document.getElementsByTagName('*') Having said that, some versions of IE5 return a zro-length collection when
'*' is used as an argument. So... /* change corrupted ¦¦ chars for pipes */
var all = document.all [b][red]¦¦[/red][/b] document.getElementsByTagName('*'); That's the simplest way to ensure that you have a collection of all elements held in a variable.
2) Don't use a
for..in loop on a collection of this kind. for..in loop will also output the length property of the collection, which may well cause an error (depending on what you are doing with the output). This construction is convenient:
for(var k=0, elm; elm=all[k++];)
{
// elm holds a reference to the element
}