Link to home
Start Free TrialLog in
Avatar of wariar
wariar

asked on

Text on the link

How can I store the text of a link in a variable?
Avatar of wariar
wariar

ASKER

How can I retrieve the hypertext on a link?
You can't... at least not in HTML alone.
Avatar of wariar

ASKER

I can try Javascript too. Thanks!
I think...

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

document['linkname'].text = Test
or
document.linkname.text = Test
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
Avatar of wariar

ASKER

I would like to accept Tyoung's answer. Thanks!
ASKER CERTIFIED SOLUTION
Avatar of TYoung
TYoung

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wariar

ASKER

Hope that helps!
Hey thanx!