RSS
 

Visited link … by CSS

22 avr

I read this article this weekend and I was really fooled by the simplicity and the efficiency of the proposed script. The author explains how he can find visited sites by using only the CSS property visited of a hypertext link.
How does it work?
In fact in the page the author « hidde » a list link of the sites he wants to test.

<a href="http://urlToTest/">MySite.com</a> ....

He also has defines a particular css property for the visited links
a:visited { .. height:100px; ... }

Then your browser makes the rest by marking the links you have already visited. It remains to go through these links and to test their offsetHeight property.

var items = document.getElementsByTagName('a'); for (var i=0,i<items.length; i++) { if (items[i].offsetHeight == 100) { //Site already visited .....

Simple and effective ….

 
No Comments

Posted by Cyril Balit in Javascript