Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Javascript] Q on 'new Image ()'


  • From: javascript@xxxxxxxxxx (Walter Torres)
  • Subject: [Javascript] Q on 'new Image ()'
  • Date: Thu, 18 Oct 2001 17:29:20 -0500

For example...

 var objImgBtn        = new Array ( 2 );           // make an array
     objImgBtn.up     = new Image ( 24, 12 );      // .up is an IMAGE Object
     objImgBtn.up.src = "./images/button-up.gif";  // source to an image
     objImgBtn.dn     = new Image ( 24, 12 );      // .dn is an IMAGE Object
     objImgBtn.dn.src = "./images/button-dn.gif";  // source to an image

<img src='' width='24' height='12' id='myBtn'>

<div id='myBtn2'></div>

Now I have 2 images in local cache, an image on a page and a DIV.

   document.all.myBtn.src = objImgBtn.dn.src;

Now the down button image from the array Object is in the <IMG> object.

   document.all.myBtn2.style.backgroundImage     = objImgBtn.dn.src;
   document.all.myBtn2.style.backgroundImage.src = objImgBtn.dn.src;

Neither line works!

   document.all.myBtn2.style.backgroundImage = "./images/button-dn.gif";

This does work, but it doesn't take advantage of the cached images.

Anybody have any ideas on how to have the DIV (or SPAN, for that matter)
take advantage the cached images in the 'objImgBtn' Object?

Thanks

Walter