when is the :visited pseudo-class applied to a hyperlink
I have some questions about the :visited
pseudo-class:
- Based on what do browsers decide when the
:visited
pseudo-class should be ap开发者_Python百科plied 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)
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.
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.
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.
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/?<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
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.
It only applies to hyperlinks (<a href>
), and when an entry is found in the browser history (not session).
精彩评论