Hey guys need your help :)
I'm trying to clone a nodelist in a bookmarklet so that I can use document.write to output each item in the nodelist to the browser.
Right now I'm basically grabbing a nodelist, iterating through it and getting stopped after the first document.write, which I think is because the nodelist reference disappears after the document is changed with document.write.
[PHP]javascript: var someElements = document.getElementsByTagName('a'); function writeElements(theElements){for(i = 0; i < theElements.length; i++){ document.write(theElements[i].href);}}; writeElements(someElements ); [/PHP]
In non booklet form:
[PHP]var someElements = document.getElementsByTagName('a');
function writeElements(theElements){
for(i = 0; i < theElements.length; i++){
document.write(theElements[i].href);
}
};
writeElements(someElements); [/PHP]
That bookmarklet will print out the first link then fail because theElement = nothing when the new page is written.
I'd really like to know how you can create a hard, deep, complete copy of an array of objects (I think that's what a nodelist is) so that I can write all of a pages links to the browser.
If there is any need for clarificaiton please let me know, thank you.