So the issue I'm having basically comes down, I have a list of external websites in HTML (as seen below).
<a id="listitem0" href="http://google.com.au/">http://google.com.au/</a><br />
<a id="listitem1" href="http://stackoverflow.com/">http://stackoverflow.com/</a><br />
<a id="listitem2" href="http://kbbdigital.com.au/">http://kbbdigital.com.au/</a><br />
<a id="listitem3" href="http://netreach.com.au/">http://netreach.com.au/</a><br />
And some of them I have visited & others I haven't, so I have CSS styling to help identify the visited vs not visited (as seen below).
<style type="text/css">
a {
color:#999999;
background-color:#000;
}
a:visited {
color:#00FF00;
background-color:#30F;
}
</style>
Visually I can see which websites have & haven't been visited, but when I run a basic javascript line it can't pick up the colour of the text or the background colour (code below), it just provides blank output.
<script type="application/javascript">
alert(document.getElementById("listitem0").style.backgroundColor);
alert(document.getElementById("listitem0").style.color);
</script>
Does anyone know why it can't pick up the colour of the text based on the CSS set earlier? And is there solution to get this?
I'm using Firefox 27.0.1 to run these tests, but have tried other browsers as well, but receive the same issue.
The detection of visited links is disabled as a privacy measure. And thanks for that.
Ref. privacy-related changes coming to CSS :visited
In short, it can't be done. That said, there might be hacks, but those would most likely quickly be patched and as a result being unreliable.
From what I read, this is implemented in most browsers.
As an example of how one could hack the history is using timing attacks. That is in short:
aleister_crowley.com
aleister_crowley.com/profile.jpg
If user has visited the page the image would load quickly due to caching in the users browser. As such you can estimate the user has, in fact, visited that page.
Then of course, this would be a case were your site has flipped to the dark side.