I read a rumour on the Internet recently that Dell were using such a script to work out whether you've visited competitor websites; allowing them to put their best offers under your nose in an aim to get your business. So under the premise that you've got a website with known competitors, how do you know if your visitor has visited them? That's where my little script would come in handy.
What it does
All I've done is create a really basic page that just has a container and a div with the ID of 'sniffer'. This is the div that I'll use for calculating whether various places have been visited. So the code is really basic here:
Sniffer is empty for now and I've just placed some instructions on the page in case you've not visited any of my test URLs.
The crucial thing to do is ensure that you're setting a color for both a:link and a:visited within the 'sniffer' div, this will ensure we can perform colour checks on them later. So all I've got is:
So for regular links I'm telling them to be blue, whereas visited links are going to be red. Note that I've commented out the layout CSS for the #sniffer div; this would position it off-page so that visitors to the page wouldn't be able to see the list I'm checking. However I've commented it out so that (for demonstrative purposes) you can see what I'm checking.