Reputation: 175
I have successfully tested visited link effect on a tag for XHTML document. But those visited link highlight with green color could not removed when I refresh the address bar on my browser except I click clear up all browser cache and history on every browser. So the question is how to reset all css when click browser refresh button without clear up browser cache and history ?
So for my site I need to do something with php code to delete all cookie or history about those site I visited , Right ?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<style>
#checkvisited{width:730px;margin-left:0px;}
#checkvisited td a{text-decoration:none;color:gray;}
#checkvisited td a:link{color:gray}
#checkvisited td a:hover{text-decoration:underline}
#checkvisited td a:active{background-color:#DEB887}
#checkvisited td a:visited{color:green}
</style>
</head>
<body><div id='checkvisited'>
<table><td><a href="http://yahoo.com" >AA</a></td><td><a href="http://yahoo.com? a=1">BB</a></td>
</table></div></body></html>
Upvotes: 3
Views: 11296
Reputation: 41
In order to get rid of different color of a:visited, i use this:
a:visited {
color: inherit;
}
If this was asked.
Upvotes: 0
Reputation: 66663
One solution is to add a randomizer to the end of href attributes of you link on page load. This way, when your page reloads, the link href is different since it has a new random value at the end.
// lets say, this is your link
var link = document.getElementById('foo');
// suffix a randomizer to the href attribute
var rand = Math.floor(Math.random() * 1000);
var href = link.getAttribute('href');
link.setAttribute('href', href + (href.indexOf('?') === -1 ? '?' : '&') + '_=' + rand);
Note: This will be useful only if the link opens in another tab/window or if it is an in-page link. Otherwise, clicking the link anyway takes the user to another page.
Upvotes: 2
Reputation: 3103
A "visited" link, i.e. one that gets picked up by the :visited
pseudo-class, is one that is in the browser's history. So, the only way to turn those links back into non-visited links is to remove them from the browser's history.
Incidentally you don't need your a:link
definition. :link
is for highlighting non-visited links. Seeing as you have a base definition for a
and a definition for a:visited
, your a:link
is redundant.
Here, however, is a proposed solution intended to defend against an attacker discovering a user's browser history by using getComputedClass
to reveal all visited links in a page:
http://dbaron.org/mozilla/visited-privacy
(Almost certainly what you are looking for, but it's useful reading on the mechanics of :visited
nonetheless)
Upvotes: 4