Created
February 15, 2011 13:32
-
-
Save noomz/827520 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<title>Test :visited</title> | |
<style> | |
a:link { color: blue } | |
a:visited { color: red } | |
</style> | |
</head> | |
<body> | |
<p>Further information: http://bhavin.directi.com/using-javascript-to-read-a-users-browser-history/</p> | |
<p> | |
<a href="http://google.com">Google</a> | |
<a href="http://adobe.com">Adobe</a> | |
<a href="http://canon.com">Canon</a> | |
<div id="result"></div> | |
</p> | |
<script> | |
/** | |
* @see http://www.quirksmode.org/dom/getstyles.html | |
*/ | |
function getStyle(el, styleProp) { | |
var x = el; | |
if (x.currentStyle) | |
var y = x.currentStyle[styleProp]; | |
else if (window.getComputedStyle) | |
var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp); | |
return y; | |
} | |
function shout() { | |
var result = document.getElementById('result'); | |
var a_s = document.getElementsByTagName('a'); | |
for (i in a_s) { | |
var color = getStyle(a_s[i], 'color'); | |
if (color == 'rgb(255, 0, 0)') { | |
result.innerHTML += a_s[i].innerHTML + ' : visited<br>'; | |
} | |
else { | |
result.innerHTML += a_s[i].innerHTML + ' : Not yet<br>'; | |
} | |
} | |
} | |
window.onload = shout; | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment