Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pulling text from between <a> tags 1

Status
Not open for further replies.

Terwin

Programmer
May 23, 2002
51
0
0
US
Hello all,

I'm attempting to put together a page indexing another page that has an extremely long list of links (350 or so).

Right now, I can obtain the document.links object and filter out the links I want, but I can't come up with a good way to obtain the actual linked text for each element in the document.links array (these links are page titles).

I don't know much about the JavaScript DOM, but I was thinking there might be a way to get the childNodes of document.links and try to get childNode values out of there somehow, but I haven't been able to come up with a solution.

Any thoughts out there?
Thanks,
T
 
Hey if you do find a way to do this could ya please tell me becuase I've been looking for something to do a similar thing...Thanks
Jammer1221
 
See if this does what you need:

Code:
<html><head><script>
function gthreftxt(){
for(i=0;i<document.links.length;i++){
     obj = document.links[i];
     alert(obj.innerHTML+' and '+obj.href);}
}
</script></head><body>
<a href=&quot;#&quot; id=&quot;lnk&quot; onClick=&quot;javascript:gthreftxt()&quot;>TEST</a>
<br><a href=&quot;[URL unfurl="true"]www.google.com&quot;>Google</a>[/URL]
</body></html>

2b||!2b
 
Yup, Lrnmore's suggestion would do it.

Had to do the same thing for a recent project. Collected the elements as an array, and then converted each member of the array into the elements innerHTML. Also had 100+ links on the page :/

----------
I'm willing to trade custom scripts for... [see profile]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top