Re: img.href object doesn't support this action
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: img.href object doesn't support this action

From: ASM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid>
Date: Wed Aug 31 2005 - 17:43:18 CEST

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
Received on Tue Oct 18 03:15:15 2005