Spyjax: Using a:visited to test your history
Written by on June 1st, 2007 in Ajax News.
Spyjax can scare you, or excite you depending on what you want to do.
By using a simple JavaScript check on the CSS style on URLs, a script can work out if you have been there:
JAVASCRIPT:
-
-
function hasLinkBeenVisited(url) {
-
var link = document.createElement(’a');
-
link.href = url;
-
document.body.appendChild(link);
-
if (link.currentStyle) {
-
var color = link.currentStyle.color;
-
if (color == ‘#ff0000′)
-
return true;
-
return false;
-
} else {
-
link.setAttribute(”href”,url);
-
var computed_style = document.defaultView.getComputedStyle( link, null );
-
if (computed_style) {
-
if (computed_style.color == ‘rgb(255, 0, 0)’)
-
return true;
-
}
-
return false;
-
}
-
}
-
Couple this with the ability to chunk this over time, and you could quickly test a lot of URLs.
Source: Ajaxian
Original Article: http://ajaxian.com/archives/spyjax-using-avisited-to-test-your-history
