Resetting visited status on links

erlando picture erlando · Oct 20, 2008 · Viewed 21.8k times · Source

Is there any way you can reset the visited status on links?

The scenario is this: On an intranet-site which naturally has a lot of links we want a link to have the status of "visited" for a set period of time only. I am therefore looking for a way to manipulate the visited status of links.

Is this doable? It should be cross-browser of course.

ETA: Client-side solutions are perfectly acceptable. Preferred even.. :-)

ETA-2: Cookies are allowed. No holds barred here :-)

Answer

ddaa picture ddaa · Oct 20, 2008

Links appear as "visited" when the browser chooses to apply the :visited CSS pseudo-class.

The client-side way to reset links to the unvisited state is to (somehow) clear the browsing history. I would be very surprised to learn there is a portable way to do it. It also has unpleasant side effects such as crippling the behavior of history-sensitive smart location bars such as the one in Firefox 3.

As Drew Noakes suggested, a server-side way is to add some noise query parameters to the links, and periodically change the query parameter. This only gives a bad approximation of the behaviour you want. To get the "correct" behavior you'd need to track the history of visited pages per user server-side, so you can change the noise parameter for a specific page only after the requisite time.

All said, it's very probably a bad idea to actually try to "reset the visited status on links".

I think a better solution would be to tweak the page style so the :visited pseudo class renders the same as the :link pseudo-class. Then keep a server-side history of visited links per user, and adjust the display of links using an explicit visited class.

If you do not have the user identity handy, and do not want to require login, you can always use a random persistent cookie.