View Full Version : How Do You Make Visited Links Become An Image

11-24-2016, 03:30 AM
I created a grid of div links and I would like to make it so that the divs become images in their :visited state. I recently discovered that this isn't possible in CSS because most browsers block this, and was told that the best workaround for this is through using Javascript.

I am still fairly new to Javascript, but I am wondering how do I take a link and make its :visited state an image using Javascript? Does anyone have any pointers? :confused:

Thank you in advance!

11-24-2016, 03:34 PM
You can't really. If you want to do so on your own site you can sort of. This is addressed in some detail here:


The fourth answer provides a function that can be used to track a user's movements via clicks on links on your site and add a class to an element (the link's parent in this case) to signify that. If you are a little familiar with javascript, it can be fairly easily adapted to add a class name to the link itself, or to do other things. As I say, it currently adds a class to the link's parent. Since I don't know what level of familiarity you have with javascript, if you need help adapting or even just using the code, let me know.

This will not, however, be able to track links visited from other sites, and that is the entire point of all of the security/prohibitions surrounding the use of the css visited pseudo class. Also, if the user has localStorage disabled, this will not work. Not too many users do though.