gramm
gramm

Reputation: 18824

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 I can't change the HTML or CSS file.

Thanks :)

Upvotes: 5

Views: 1764

Answers (4)

kristof
kristof

Reputation: 53824

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.

Upvotes: 0

Bart van Heukelom
Bart van Heukelom

Reputation: 44094

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; }

Upvotes: 1

Gumbo
Gumbo

Reputation: 655209

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.

Upvotes: 0

Noon Silk
Noon Silk

Reputation: 55072

Indeed, it is possible.

One way is to have different css classes:

a:visited { color : red; }
a { color : orange; }

Then detect that (in JavaScript).

Upvotes: 3

Related Questions