javascript - know if a link has already been opened
I'd like to know if there is a way to know if a link has already been opened. In firefox, the color of a link changes once you clicked it, so I guess it's possible.
Edit : This is for a firefox extension, so开发者_StackOverflow I can't change the HTML or CSS file.
Thanks :)
Indeed, it is possible.
One way is to have different css classes:
a:visited { color : red; }
a { color : orange; }
Then detect that (in JavaScript).
If you don't want the links to have different colours, you can also apply some CSS that will turn out invisible
a:visited { padding-left: 1px; margin-left: -1px; } a { padding-left: 2px; margin-left: -2px; }
You could specify different colors for unvisited (:link
) and visited links (:visited
) and check if the current color of your link has the visited’s one.
Unfortunately it is possible to see what links were visited. I am saying unfortunately as it is considered a privacy violation. A while ago I came across this blog post Spyjax – Your browser history is not private! which describes this.
精彩评论