[X]

Reading Your History With CSS

browser tricks 2002 dead

Style visited links purple, read the colour back with JavaScript, and you have just read the visitor's browsing history.

In 2026: Dead, deliberately. Browsers have lied to this script since 2010: getComputedStyle always reports the unvisited colour, and :visited itself is restricted to colour changes only, so layout tricks cannot leak it either. Before the fix, demo pages cheerfully listed which banks and forums you had been to. One of the few entries here that was killed for working too well.

Where it came from: Filed against Mozilla as bug 57351 in 2000, exploited widely from about 2002, fixed across browsers starting in 2010. MDN

<style>
#probe a         { color: #0000ee; }  /* unvisited: blue  */
#probe a:visited { color: #551a8b; }  /* visited: purple  */
</style>

<div id="probe">
  <a href="http://www.google.com/">google</a>
  <a href="http://www.geocities.com/">geocities</a>
</div>
<ul id="report"></ul>

<script type="text/javascript">
// Read each link's colour back. Purple meant the visitor had been there.
var links = document.getElementById("probe").getElementsByTagName("a");
for (var i = 0; i < links.length; i++) {
  var col = getComputedStyle(links[i], null).color;
  document.getElementById("report").innerHTML +=
      "<li>" + links[i].innerHTML + " reports " + col +
      " (the browser says: never visited)</li>";
}
</script>
sandboxed demo · breaks nothing but itselfrestart

More in browser tricks

all 25 in browser tricks › · the whole library ›