469,353 Members | 2,113 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,353 developers. It's quick & easy.

img.href object doesn't support this action

Hi i have this code

var newsTab=document.getElementById("newsTab");
newsTab.href="latestTabClosed.gif";

where "newstab" is an Image placeholder
<img name="newsTab" id="newsTab" src="" width="256" height="32" alt="News
Tab">

In the documents i've read this is the way to dynamically change an image
but all i get is a "Object doesn't support this action" error. Why?

Thanks in advance.
Aug 31 '05 #1
3 4317
ASM
Darren wrote:
Hi i have this code

var newsTab=document.getElementById("newsTab");
newsTab.href="latestTabClosed.gif";

where "newstab" is an Image placeholder
<img name="newsTab" id="newsTab" src="" width="256" height="32" alt="News
Tab">
Try to have not same name for name/id and for JS object
In the documents i've read this is the way to dynamically change an image
but all i get is a "Object doesn't support this action" error. Why?


because :
it is not 'href' but 'src' that calls image file <img SRC="file.jpg">

newsTab.document.getElementById("newsTab");
newsTab.src = "latestTabClosed.gif";
or
newsTab.document.images["newsTab"];
newsTab.src = "latestTabClosed.gif";
or
document.images["newsTab"].src = "latestTabClosed.gif"
or
document.getElementById("newsTab").src = "latestTabClosed.gif";

--
Stephane Moriaux et son [moins] vieux Mac
Aug 31 '05 #2
ASM wrote on 31 aug 2005 in comp.lang.javascript:
newsTab.document.getElementById("newsTab");
newsTab.src = "latestTabClosed.gif";
newsTab = document.getElementById("newsTab");
newsTab.src = "latestTabClosed.gif";
or
newsTab.document.images["newsTab"];
newsTab.src = "latestTabClosed.gif";
newsTab = document.images["newsTab"];
newsTab.src = "latestTabClosed.gif";
or
document.images["newsTab"].src = "latestTabClosed.gif"
or
document.getElementById("newsTab").src = "latestTabClosed.gif";


--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Aug 31 '05 #3

"ASM" <st*********************@wanadoo.fr.invalid> wrote in message
news:43**********************@news.wanadoo.fr...
Darren wrote:
Hi i have this code

var newsTab=document.getElementById("newsTab");
newsTab.href="latestTabClosed.gif";

where "newstab" is an Image placeholder
<img name="newsTab" id="newsTab" src="" width="256" height="32" alt="News Tab">
Try to have not same name for name/id and for JS object
In the documents i've read this is the way to dynamically change an image but all i get is a "Object doesn't support this action" error. Why?


because :
it is not 'href' but 'src' that calls image file <img SRC="file.jpg">

See that's what i thought but the document i read used href and trying it
with src would have been far too sensible. :)
newsTab.document.getElementById("newsTab");
newsTab.src = "latestTabClosed.gif";
or
newsTab.document.images["newsTab"];
newsTab.src = "latestTabClosed.gif";
or
document.images["newsTab"].src = "latestTabClosed.gif"
or
document.getElementById("newsTab").src = "latestTabClosed.gif";
Well despite the typo in the above i wish all documentors were as thorough
as you. :)
Thanks Stephene --
Stephane Moriaux et son [moins] vieux Mac

Sep 1 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Marcello | last post: by
9 posts views Thread by Kreso | last post: by
53 posts views Thread by usenet | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.