If you would like to understand more of its internal functionality, I would suggest taking a look at the comprehensive course: JavaScript for beginners - learn by doing
function check_visited_links(){
var visited_links = JSON.parse(localStorage.getItem('visited_links')) || [];
var links = document.getElementsByTagName('a');
for (var i = 0; i < links.length; i++) {
var that = links[i];
that.onclick = function () {
var clicked_url = this.href;
if (visited_links.indexOf(clicked_url)==-1) {
visited_links.push(clicked_url);
localStorage.setItem('visited_links', JSON.stringify(visited_links));
}
}
if (visited_links.indexOf(that.href)!== -1) {
that.parentNode.className += ' visited';
}
}
}
if you want to add some styling just add the following CSS rule:
.visited{
color:silver
}