PDA

View Full Version : Javascript help - check href value



dombrorj
01 Feb 2010, 03:06 AM
I'm trying to make a script check the href value of the link. If the href is not what it should be, then the script will change it to the correct link.

Here's what I have so far, but it doesn't seem to be working. Also, I'd like the mousover to show the href value at all times.

Can anyone figure out how to make this work and add the mousover element?




<a id="test" href="http://test.com">test link</a>

<script>
if(document.getElementById('test').href != 'http://correctlink.com') {
document.getElementById(‘test').href = 'http://correctlink.com';
}
</script>

Thanks for the help.