By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,687 Members | 2,046 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,687 IT Pros & Developers. It's quick & easy.

img.href object doesn't support this action

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a

"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.