Created
May 20, 2015 06:19
-
-
Save alexcican/fdc28a0a9ce627bd666a to your computer and use it in GitHub Desktop.
Adding :visited styling to visited links with JS (CSS: a[data-visited])
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
localStorage.setItem('visited-'+window.location.pathname,true); | |
var links = document.getElementsByTagName('a'); | |
for (i=0;i<links.length;i++) { | |
var link = links[i]; | |
if (link.host == window.location.host | |
&& localStorage.getItem('visited-' + link.pathname + '/')) { | |
link.dataset.visited = true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment