Connecting Tech Pros Worldwide Forums | Help | Site Map

query: colour changing text

xtrmntr: a northern soul
Guest
 
Posts: n/a
#1: Jul 20 '05
alright there,
i'm pretty much throwing myself on everyone here's mercy, as i'm
struggling to even articulate what i mean, never mind create the
behaviour i want.

i've a website with a navigational frame on the bottom, and the main
site taking up the other 90% of the window. each page has got a
different background colour, where as the navigational frame obviously
stays the same.

is there a way that, when i click on one of the links in the
navigational frame, the colour of the text, still in this frame, would
change according to which link i click? from, for example, red, to
yellow or green depending on whether i choose 'pictures' or 'stories',
to match the colour scheme?

well, any help or anything much appreciated,
regards, mark.

Yann-Erwan Perio
Guest
 
Posts: n/a
#2: Jul 20 '05

re: query: colour changing text


xtrmntr: a northern soul wrote:
[color=blue]
> i've a website with a navigational frame on the bottom,[/color]

That you should avoid, if possible:-)
[color=blue]
> navigational frame, the colour of the text, still in this frame, would
> change according to which link i click?[/color]


<div id="navbar" onclick="foo(this, event)">
<a id="foo1" href="foo1.html" target="main">foo1</a>
<a id="foo2" href="foo2.html" target="main">foo2</a>
<a id="foo3" href="foo3.html" target="main">foo3</a>
</div>

<script type="text/javascript">
function foo(bar, evt){
var d=document, a, c, t;
var colors={
"foo1":"yellow",
"foo2":"green",
"foo3":"maroon"
};
if(bar && bar.getElementsByTagName &&
typeof bar.parentNode!="undefined"){

t=evt.srcElement||evt.target;
while(t.nodeType!=1)t=t.parentNode;
if(t && t.href){
a=bar.getElementsByTagName("a");
c=colors[t.id]||"black";
for(var ii=0; ii<a.length; ii++){
a[ii].style.color=c;
}
}

}
}
</script>
Closed Thread