/    Sign up×
Community /Pin to ProfileBookmark

Need help with a change text color fonction…

Hello everybody !!!
What I want to do might seem a bit odd. Here it is :
I’m making a website, and I’m using frames. On the left, I have my navigation menu, which consists of a series of links in a table. vers simple, indeed.
What I want to to, is have the link change color when the page corresponding to it is loaded in the mainFrame.
Like, if I click on the link “works”, I want the page works.htm to load into the mainFrame ( obviously ), but I also want the word Works in the linklist to become red instead of black, indicating which page the user is currently browsing.
I thought I could do it with a simple CSS, giving the red color to my a:active, but when I click elsewhere, the link loses its red color and becomes black again.
Here’s what I’ve found so far :
I was planning to make a Js function, which would color the link when the user clicks on it ( like a document.getElementById(“the element id”).style.color=”red”; and attributing an Id to the corresponding element ) but then, I noticed something… If the user clicks on the link “Works”, this one will become red, okay, but then , what happens when he clicks on another link, like “People” ? “People” will become red, but “Works” will stay red too…
I’m lost…
If you could help me, I would be eternally gratefull !!!!
I’m really a total beginner in Javascript, but I tried to search a bit on my own before begging for help… ?
NesS

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@JonaSep 07.2004 — [font=trebuchet ms]Put this in the HEAD tag of your left frame.[/font]

<i>
</i>&lt;script type="text/javascript"&gt;
function colorLink(link){
links = document.links;
if(!links) return;
for(var j=0; j&lt;links.length; j++){
links[j].style.color="black";
}
link.style.color = "red";
}
&lt;/script&gt;


[font=trebuchet ms]Use this for each of the links.[/font]

<i>
</i>&lt;a href="works.html" target="mainFrame" onclick="colorLink(this);"&gt;Works&lt;/a&gt;
Copy linkTweet thisAlerts:
@Ness_du_FratauthorSep 07.2004 — waooo, great !!!! It works just perfectly !!!!

You are my saviour !!! *hugs*

BTW, do you know ( I'm sure you do ) how I could make the active link become bold ? And then, becomes normal again ? This is not really important, but it would be totally great !!!! ?)))
Copy linkTweet thisAlerts:
@JonaSep 07.2004 — [font=trebuchet ms]More than happy to help. ? [/font]

<i>
</i>&lt;script type="text/javascript"&gt;
function colorLink(link){
links = document.links;
if(!links) return;
for(var j=0; j&lt;links.length; j++){
links[j].style.color="black";
links[j].style.fontWeight="normal";
}
link.style.color = "red";
link.style.fontWeight="bold";
}
&lt;/script&gt;
Copy linkTweet thisAlerts:
@Ness_du_FratauthorSep 07.2004 — Sorry, I was just going to post that I found out for the bold thing, but you were really quick !!!!

Thanks a lot, it's really exactly what I wanted, and it's something really usefull for me...

*gives big big hug*

THANKS !!!!!!! ?

NesS
Copy linkTweet thisAlerts:
@JonaSep 07.2004 — [font=trebuchet ms]Happy to help, Ness. ? [/font]
×

Success!

Help @Ness_du_Frat spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.3,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...