...

View Full Version : change link color when clicked



sassy_monix
12-20-2004, 08:31 AM
Hi!

I have menu in my page and an iframe that changes when the links in the menu are clicked. What I want to do is change the color of the link of the current page that is shown in the iframe. I guess it's just the same as change the color of the link once it is clicked. Is there any way for me to do this using Javacript?

I would really appreciate any kind of help. Thanks!

Willy Duitt
12-20-2004, 09:22 AM
Check the source of the iframe and loop thru the parent document.anchors collection to match it with the one that has the same href value and change the class...

.....Willy

mindlessLemming
12-20-2004, 09:37 AM
Willy's suggestion is right on the money -- that would be the best way to go about it.
The easiest way to go about it would be like so:


<a href="page2.htm" onclick="this.style.color = '#3aad22' ">Page 2</a>


If you do decide to take the easy way out, don't do so unless you understand why Willy's suggestion is a better method. :)

jbot
12-20-2004, 10:26 AM
eh ... CSS anyone?



a:link {color: blue;}
a:active {color: red;}
a:visited {color: purple;}


the exact colours are up to you, of course.

sassy_monix
12-20-2004, 01:11 PM
Thanks for your replies but what I need is something that when you click another link in the menu the current link goes back to its original color and the one clicked will change.

The code snippet of mindlessLemming works great but if I could just find a way to modify it so that it would work like I mentioned above.

Looking forward to all your help again. thanks! :)

ArcticFox
12-20-2004, 08:26 PM
[...]something that when you click another link in the menu the current link goes back to its original color and the one clicked will change.



a:link {color: blue;}
a:active {color: red;}
a:visited {color: blue;}




:)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum