Use jQuery to Select Visited Links
The given approach has been disabled for security reasons.
As it is possible to retrieve a visitor's history by checking for visited links, certain measures have been taken by browser vendors to prevent this.
Source: Mozilla Foundation Blog.
Checked in Chrome and FF - both don't support $("a:visited")
any longer.
I found workaround based on LocalStorage on Nevyan's Blog: Mark visited links using JavaScript and localStorage
He proposed clean JavaScript code to store links clicked by page user in LocalStorage and add class "visited" to parent of an <a>
element:
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';
}
}
}
I don't know if it's safer than :visited approach though.