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?
JavaScript

Avatar of undefined
Last Comment
Arthalius
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of leakim971
leakim971
Flag of Guadeloupe image

...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?
JavaScript
JavaScript

JavaScript is a dynamic, object-based language commonly used for client-side scripting in web browsers. Recently, server side JavaScript frameworks have also emerged. JavaScript runs on nearly every operating system and in almost every mainstream web browser.

127K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo