Link to home
Start Free TrialLog in
Avatar of Arthalius
Arthalius

asked on

What am I missing?

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?
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
...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

Avatar of Arthalius
Arthalius

ASKER

Doh! How'd I miss that?