Forum Moderators: phranque

Message Too Old, No Replies

images

         

zxk105

1:34 am on Sep 10, 2004 (gmt 0)

10+ Year Member



I was wondering if something like this is possible to do with HTML and JavaScript:

img1off = new Image();
img1off.src = "images/home_off.gif";

<img src='img1off.src' name="img1" width="100" height="30" border="0">

When I look at the page in the browser there is no image. Is there a way to do this or do I have to use:

<img src="images/home_off.gif".....>

Thanks

TheDoctor

8:33 pm on Sep 10, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Not sure what you're really getting at, but here's the literal answer to your question:

<img src="images/home_off.gif".....> will work.

Otherwise, if you're genuinely using something that varies, in your Javascript try


document.write('<img src="' + img1off + '" name="img1" width="100" height="30" border="0"');

after assigning a string containing the file name of the image (eg "images/home_off.gif") to img1off.

If this is not really what you want, perhaps you could explain a bit more.