Text on the link

How can I store the text of a link in a variable?
wariarAsked:
Who is Participating?
 
TYoungConnect With a Mentor Commented:
Will you? I need some points.
click the:
Click Here To Accept Comment As Answer
0
 
wariarAuthor Commented:
How can I retrieve the hypertext on a link?
0
 
gravityCommented:
You can't... at least not in HTML alone.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
wariarAuthor Commented:
I can try Javascript too. Thanks!
0
 
deepchandaCommented:
0
 
TYoungCommented:
I think...

<a href="asdf" name="linkname">Test</a>

document['linkname'].text = Test
or
document.linkname.text = Test
0
 
nigesCommented:
I would say the best way to do it would be to use ASP as it is quick and easy. Up the top of the page have a block of text like
<%
   DIM strLinkText
   strLinkText = "whatever"
%>

And then further in the page where you have the link put:
<a href="http://blah" name = "<%=strLinkText%>"><%=strLinkText%></a>

and it should work

then whenever you want to use the link text, all you need to do is type
<%=strLinkText%> and the content of the linktext will be displayed on the screen. If you would like to use it over multiple pages, you can put it in a session variable with the command

session("LinkText") = strLinkText after it has had a value put in it, and then you can refer to it (within your session timeout period - usually around 20 minutes) with
<%=session("LinkText")%> on any page in the current site.

Cheers,

Nige
0
 
wariarAuthor Commented:
I would like to accept Tyoung's answer. Thanks!
0
 
wariarAuthor Commented:
Hope that helps!
0
 
TYoungCommented:
Hey thanx!
0
All Courses

From novice to tech pro — start learning today.