TheCandyman
Technical User
I'm having trouble with this simple JS. It looks at the anchor tag in the URL, breaks it into an array (which works) and changes the background color based on that value which is where i get an error. I can see the correct value saved in 'anchorValue' (a2697), but get an error saying it's unable to get the value of the property 'style': is null or undefined. What did i miss?
Code:
<script type="text/javascript">
var anchorValue;
var url = document.location;
var strippedUrl = url.toString().split("#");
if(strippedUrl.length > 1)
anchorValue = strippedUrl[1];
alert(anchorValue);
document.getElementById(anchorValue).style.backgroundColor='white';
</script>
...
...
...
<li><a name="a2697"></a>......