What am I missing?

Arthalius
Arthalius used Ask the Experts™
on
OK, I'm trying to do something here that should be fairly simple. I have an A located in my code that needs to have a different HREF value based upon the browser and some other data the user enters. The problem is that I cant get this to work. Here is an example of a greatly simplified version of the code that is producing the problem :

<a id="fms" class="player" style="display:block;width:624px;height:352px" href="#">
     <img src="/flowplayer/intro.png" alt="Click here to start playback" width="624px" height="352px" border="0" />
</a>

<script type="text/javascript" >
     document.getElementByID("fms").href = "http://www.google.com";
</script> 

Open in new window


In FF, the code simply doesn't work. In IE8, the code fails with the error message, "Object doesn't support this property or method". I've looked up the docs and it looks to me like this SHOULD be working. Any ideas?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Multitechnician
Top Expert 2014
Commented:
Id not ID :

document.getElementById
leakim971Multitechnician
Top Expert 2014

Commented:
...assuming the script is inside the body and after the anchor else, if the script is inside the head section, use :
<head>
<script type="text/javascript" >
window.onload = function() {
     document.getElementById("fms").href = "http://www.google.com";
}
</script> 
</head>

<body>
<a id="fms" class="player" style="display:block;width:624px;height:352px" href="#">
     <img src="/flowplayer/intro.png" alt="Click here to start playback" width="624px" height="352px" border="0" />
</a>
</body>

Open in new window

Author

Commented:
Doh! How'd I miss that?

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial