/    Sign up×
Community /Pin to ProfileBookmark

onclick the link color will be changed

Hi all

I have a group links.

<a href=”a.html”>LINK A</a>

<a href=”b.html”>LINK B</a>

<a href=”c.html”>LINK C</a>

all these three links have color black if not clicked.Now if i click LINK B then it will goes to b.html and there the color of LINK B will be changed into green.but others 2 will remain black.

Is it possible?As i am a newbie in javascript and learning too…so please suggest me your best ideas.

Thanks for your co-operation in advance.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@KorOct 05.2006 — Insert these CSS and Javascript codes in the head of each of your pages. You may adjust the color in CSS classes. You may insert all the relative url of your pages in the array [B]var L[/B]
<i>
</i>&lt;style type="text/css"&gt;
&lt;!--
a.black{
color:#000000;
}
a.black:visited{
color:#000000;
}
a.green{
color:#006600;
}
a.green:visited{
color:#006600;
}
--&gt;
&lt;/style&gt;
&lt;script type="text/javascript"&gt;
onload=function(){
var L=['a.html','b.html','c.html']
var A=document.getElementsByTagName('a');
var i=0, myA
while(myA=A[i++]){
var j=0, myL
while(myL=L[j++]){
var reg=new RegExp(myL);
myA.href.match(reg)?myA.className=location.href.match(reg)?'black':'green':null
}
}
}
&lt;/script&gt;
Copy linkTweet thisAlerts:
@raj_2006authorOct 05.2006 — hi thanks for your suggestions....its working...great

Now i have a css class called left_menu

.left_menu:hover{

color: #95C864;

background-image: url(images/left_menu_g.gif);

background-position: left;

background-repeat: no-repeat;

padding-left: 15px;

text-decoration: underline;

}

.left_menu:active{
color: #95C864;
background-image: url(images/left_menu_y.gif);
background-position: left;
background-repeat: no-repeat;
padding-left: 15px;
text-decoration: underline;
}


.left_menu:nounderline{text-decoration:none}{

color: #95C864;

background-image: url(images/left_menu_y.gif);

background-position: left;

background-repeat: no-repeat;

padding-left: 15px;

text-decoration: underline;

}

and the links are

<a href="personaldetails.php" class="left_menu">Accounts</a>


<a href="addaccount.php" class="left_menu">Digital Accounts</a>


<a href="addamount.php" class="left_menu">Exchange </a>

Now how can i adjust these classes with the javascript?

Please advice
×

Success!

Help @raj_2006 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 6.16,
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: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

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