Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

a:visited 1

Status
Not open for further replies.

kimb

Technical User
Jun 30, 2002
39
0
0
NZ
Hi, Someone HELP! I've always had a problem with the a:visited hyperlink, that if I add attributes to it, the specified attributes show up every time, once a page has been visited once.

I've pretty much ignored the class, but now I'm studying Designing without Tables and would like to try again.

Is there any way that attributes can show only when you are actually on the page and if you return to the page it doens't still contain those attributes (I hope I'm making sense)

I have the order of classes correct:

a:link
a:visited
a:hover
a:active

but the same thing is happening.

Thanks
Kim
 

The visited state is probably tied in with the browser's history. if you clear that, the link would probably show unvisited.

One way around this might be to append a random query string to the href of each anchor (using onclick), in the hope that when the page is added to the history, it is added with the query string, and so the links don't count as visited.

Hope this helps,
Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
Demonstrating the sensible solution Dan already suggested:
Code:
<a href="[URL unfurl="true"]http://.com"[/URL] onmousedown="this.href += '?'+Math.random()";>point here</a>
Or to get every link on the page
Code:
<script language="javascript">
window.onload = init;
function init(){
var links = document.getElementsByTagName('A');
for (c=0;c!=links.length;c++) links[c].href += '?'+Math.random();
}
</script>
You could do the same server-side for compatibility with non-JS browsers.

--Glen :)

Memoria mihi benigna erit qui eam perscribam
 
IMO random query strings generate lots of noise in browser's history.

Plus... if all links always have unique random suffix, neither link will be marked as "visited". This is same as making a:link equal a:visited, correct?

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
Kim, Something simple like this is probably all you need.
Code:
<html><head>
<style>
a {font-family: "arial", "sans-serif"; font-size:12px; 
   font-weight:bold; color:blue; text-decoration:none}
a:hover  {color:red}
a:focus  {color:purple; -moz-outline: none; outline: none}
a:active {color:purple; -moz-outline: none; outline: none}
</style>
<body>
<a href="[URL unfurl="true"]http://tubularity.com"[/URL] target=_blank>Tubularity</a><br />
<a href="[URL unfurl="true"]http://port-lucaya.com"[/URL] target=_blank>Port Lucaya</a>
</body></html>
***********************************************************

Clive
 
I've always had a problem with the a:visited hyperlink, that if I add attributes to it, the specified attributes show up every time, once a page has been visited once.
Err... that's what the [tt]:visited[/tt] pseudo-class does - apply to links that you have already visited. The clue's kinda in the name.

Are you looking for a way to highlight the current page in a menu of links to all pages on your site? [tt]:visited[/tt] isn't going to help you there.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
a:active is the one meaning that you have the page open it is -active- and once you return back to the page it will not still show the active attributes.

in the begining man created code.
in the end code will create man.
clones are coming only matter of time.
examples?
 
a:active is the one meaning that you have the page open
No it isn't. [tt]:active[/tt] applies to a link that is currently being activated - i.e. you are actually clicking on the link. At least that's what it's supposed to apply to, IE applies it to links that have the focus as you tab through them with the keyboard. You can find further, ahem, discussion of [tt]:active[/tt] in thread215-1049865 .

There isn't a built-in pseudo-class that identifies links pointing to the current page. Some accessibility experts will tell you that you shouldn't have any such links anyway. If you do have them, you can add your own class to identify them:
Code:
<ul id="menu">
  <li><a class="current" href="this.htm">This Page</a></li>
  <li><a href="other.htm">Other Page</a></li>
  <li><a href="another.htm">And Another</a></li>
</ul>


-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Thanks Chris, adding a separate class to the current page is the one that worked.
Kim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top