6

I would like to remove a link from a page when it was visited. But...how, if the pseudo-class :visited have privacy restrictions? (i can not use display: none, for example)

(How i would like to do) Example:

.someclass a:link {display:block;}

.someclass a:visited {display:none;}

Thanks guys.

Detail: i'll use a external link too, so i can not use jquery cookies or localstore, and the links will be delivered by email, therefore i can not use jquery on click in the class "X".

Iago
  • 1,214
  • 1
  • 10
  • 19
  • Does this fiddle capture your problem? http://jsfiddle.net/NGSs8/ – megawac Feb 06 '14 at 17:33
  • +1 Interesting question. I try this and for Chrome I figured out that `:visited` is used only for links which user visit from the site. Then, you're not able to check if user has ever been on referenced site before. You should try catch `click` event, store the cookie with link URL and when user go back to your site you will store site url in coolies into database and do not render visited link for user. – Boris Šuška Feb 06 '14 at 17:43
  • possible duplicate of [Why doesn't this a:visited css style work?](http://stackoverflow.com/questions/8331688/why-doesnt-this-avisited-css-style-work) – showdev Feb 06 '14 at 17:45
  • 1
    If you're delivering these links by email, you won't be able to change an already delivered email. Are you hoping that the CSS will be able to hide it inside of the email? – ntgCleaner Feb 06 '14 at 17:45
  • Hello Boris, i'll use a external link and this doesn't work correctly, because i'll send the links via email too. – Iago Feb 06 '14 at 17:56
  • Sorry showdev, i found much askes, but nothing worked and i'm sending my case to search some solution to this. – Iago Feb 06 '14 at 17:57
  • No ntg, the page will be changed, not the email. I want only show a link when the user visited the link, is a perpetual launch and the links of the videos will be sent to the leads email. – Iago Feb 06 '14 at 17:58
  • Related [CSS :link and :visited pseudo-classes - are web browsers adhering to the spec?](http://stackoverflow.com/questions/7792010/css-link-and-visited-pseudo-classes-are-web-browsers-adhering-to-the-spec) – megawac Feb 06 '14 at 18:16

2 Answers2

4

The only attribute you can change via the :visited pseudo-class is the color. This is in response to a security issue where javascript could be used to measure the computed style of a link and determine if the user had visited that url. This has been patched in the recent years, so you should avoid relying on it for functionality like you are desiring. See the article here for a more detailed description:

http://www.impressivewebs.com/styling-visited-links/

1

I think the closest you can get is to color the visited link same color as background e.g.

a:link {display:block;}
a:visited {color:white}

http://jsfiddle.net/NGSs8/5/

Yuriy Galanter
  • 38,833
  • 15
  • 69
  • 136