Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > how to change link.text color dynamically ?

Reply
Thread Tools

how to change link.text color dynamically ?

 
 
Margaret Asami
Guest
Posts: n/a
 
      09-30-2003
I have 2 frames, one frame is a table of content with a bunch of links, and
the other frame houses the contents. I want to be able to change the color
of the link text when the user clicks on it.

I tried this:
var name = document.links[0].text;
name.fontcolor("yellow");

but didn't work, probably because "name" is a copy, not a reference to the
link object property right ? Can anyone help ? Thanks a bunch in advance!!

Regards,
Margaret
 
Reply With Quote
 
 
 
 
Ivo
Guest
Posts: n/a
 
      09-30-2003
"Margaret Asami" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I have 2 frames, one frame is a table of content with a bunch of links,

and
> the other frame houses the contents. I want to be able to change the color
> of the link text when the user clicks on it.
>
> I tried this:
> var name = document.links[0].text;
> name.fontcolor("yellow");


document.links[0].style.color="yellow";

>
> but didn't work, probably because "name" is a copy, not a reference to the
> link object property right ? Can anyone help ? Thanks a bunch in advance!!


name is a reference (I think) to the text attribute of document.links[0].
Since no such attribute exists in any DOM I know, its value will be null if
read, and be of no direct consequence if written. Perhaps you 're confused
with the innerText or innerHTML attibutes.
Style is an attribute, itself having such attributes as background,
backgroundcolor, border, padding, etc. etc. These can all be read and
written.
fontcolor() is a function which will wrap font tags (I think, perhaps span
tags) around a string. For it to be of any use, that string must then be
used elsewhere. HTH
Ivo
>
> Regards,
> Margaret



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Changing font color from current font color to black color Kamaljeet Saini Ruby 0 02-13-2009 04:58 PM
Best way to dynamically change background color of a span or div? Boonish HTML 4 09-30-2006 09:01 AM
Change text color for one document.write but not color of all text? kroger@princeton.edu Javascript 7 02-02-2005 01:23 PM
Change text color of "visited link" back to unvisited color ??? Matt Adams HTML 0 08-26-2003 10:27 AM



Advertisments