Replacing text and object required error

C

contact

Hi, I'm trying to use the following to replace a text string in all the
links on a page:

var arrLinks = document.links;
for(var LinkIterator = 0; LinkIterator < arrLinks.length;
LinkIterator++) {
if(arrLinks[LinkIterator].firstChild.nodeValue == "More
Information"){
arrLinks[LinkIterator].firstChild.nodeValue = "More";
};
};

I'm getting an object required error for this line:

if(arrLinks[LinkIterator].firstChild.nodeValue == "More Information"){

Why is that? Also, I've placed this code near the bottom of the page.
Is this the correct way to do it? Should I be placing it in a function
and calling that? I'm a bit new to this. Thanks for your help.
 
T

Thomas 'PointedEars' Lahn

var arrLinks = document.links;
for(var LinkIterator = 0; LinkIterator < arrLinks.length;
LinkIterator++) {
if(arrLinks[LinkIterator].firstChild.nodeValue == "More
Information"){
arrLinks[LinkIterator].firstChild.nodeValue = "More";
};
};

I'm getting an object required error for this line:

if(arrLinks[LinkIterator].firstChild.nodeValue == "More Information"){

Why is that? Also, I've placed this code near the bottom of the page.
Is this the correct way to do it?

Does `arrLinks' even evaluate to an object reference?
Does `arrLinks[LinkIterator]' etc.?

<http://www.pointedears.de/scripts/test/whatami>, § 2.

Anyway, the above code should be called in the `onload' event handler
attribute value of the document's `body' element to make sure the DOM
tree it is operating on was completely built.


HTH

PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,225
Members
46,815
Latest member
treekmostly22

Latest Threads

Top