简体   繁体   中英

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 :)

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

您可以为未访问的( :link )和访问过的链接( :visited )指定不同的颜色,并检查链接的当前颜色是否具有访问者的颜色。

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM