views:

46

answers:

6

I have some questions about the :visited pseudo-class:

  • Based on what do browsers decide when the :visited pseudo-class should be applied to a hyperlink?
  • Do they take this information from the browser's page history or is it stored per-session or somewhere else?
  • Is it possible (for the developer of a web page) to control for how long the :visited pseudo-class should be applied to hyperlinks?

(Note: I'm not trying to solve an actual problem, I'm just wondering how it works)

+4  A: 

It's applied when a link has been visited based on the browser history. Clearing your history will clear the visited state. There's no "timeout", as far as I know.

Ivo van der Wijk
+1  A: 

It's usually stored in the browser's page history (not per session, except in the case of some sort of privacy mode perhaps).

It simply checks if that link exists in the history, if so it's :visited. As far as I'm aware, you can't control how long it's applied in any way.

Nick Craver
A: 

It only applies to hyperlinks (<a href>), and when an entry is found in the browser history (not session).

Lekensteyn
A: 

The :visited argument is stored in a users history file, and can only be removed locally. There is no way to controll that from a server

why do you want to set a timeout for it? maybe there is another way to get what you need.

what you can do is create a random parameter in your link like:

http://www.yourdomain.com/?&lt;random argument>

this way the link always difers, is directed to the same link and then you just throw away the parameter.

@edit yes, it is possible, if you set a cookie and the per user check the last time the cookie was set per link(include the parameter), and if time > the time you want, refresh the parameter

Nealv
I don't want to set a timeout, I was just wondering whether it is possible. The hint with the changing query string parameter is good.
M4N
Ok, still, might be interesting to know why you want it to be possible
Nealv
@Nealv: I don't have an actual problem I'm trying to solve. I was just wondering how it works.
M4N
A: 

You can kind of control it to your advantage by changing the link itself when its target changes. For example, I've seen some message board software that would append the message count to its topic links on the front page, so that the links you have visited would become unvisited when a new message appears in them.

Radomir Dopieralski
A: 

well almost everything has been covered except one thing. when does it get applied? when the target page has its onload event. so not immediately. if you open the link in a new tab in the backgorund you will see some delay before it switches its style. tahts exactly the time the external page takes to load and for the browser to store history/trigger the change.

Joe Hopfgartner