Solved

Changing a link to visited

Posted on 2003-10-26
4
177 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 Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

828 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