Solved

Changing a link to visited

Posted on 2003-10-26
4
174 Views
Last Modified: 2013-12-25
Is there a way in Javascript to change a link to visited?  I have the following style:
a.external:visited {
      text-decoration:none;
      color:ffffff;
      font-weight:bold
}
a.external:active {
      text-decoration:none;
      color:ffff00;
      font-weight:bold
}
a.external:link {
      text-decoration:none;
      color:ffffff;
      font-weight:bold
}

to have the active link in yellow, with all others (in this class) in white.  This part works correctly.

Now I want one link to start as yellow then behave as the external class does above.

It seems easiest to be able to "click" that link onLoad to make it visited.

Anyone have any ideas or a different solution?

Thanks!
0
Comment
Question by:kkbenj
4 Comments
 
LVL 17

Expert Comment

by:dorward
ID: 9771500
You can not change the visited state of a link with JavaScript.

You could do something like:

<a href="whatever" class="yellow" onmousedown="this.class='external';" onkeydown="this.class='external';">

although I'm not entirely clear what you want to achieve or why.
0
 
LVL 25

Accepted Solution

by:
Rouchie earned 500 total points
ID: 9893783
If you want the link text to stay as VISITED, you can alter the order in which you declare the styles.  Link styles are declared in reverse-order of importance, so the last option always take priority over the previous one etc.

I'm not entirely sure what you're trying to achieve, but try this, then post some more details if required;

a.external:active {
     text-decoration:none;
     color:ffff00;
     font-weight:bold
}
a.external:link {
     text-decoration:none;
     color:ffffff;
     font-weight:bold
}
a.external:visited {
     text-decoration:none;
     color:ffffff;
     font-weight:bold
}

If you need to use the :hover class, also use this before the :visited one.
0
 
LVL 8

Expert Comment

by:CoolATIGuy
ID: 10379150
kkbenj,

Please deal with this old thread...


CoolATIGuy
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Problem to be resolved in this article Currently, development of website and web application can be done without writing thousands of lines of programming code by hand. Description This can be done through by using a open source framework such …
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
This video teaches users how to migrate an existing Wordpress website to a new domain.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now