Groups | Blog | Home
all groups > asp.net > november 2003 >

asp.net : pre-loading images (script?)



VR
11/16/2003 11:33:48 PM
Hi,

I am trying to have a menu item (which is an HTML img) to
change as a mouse moves over it. So, my code looks
something like this:

<a
onmouseover="ActivateImage('MyImage');"
onmouseout="InactivateImage('MyImage');"
href="javascript:void(FollowLink('MyImage'));">
<IMG height="22" src="Image1.gif" name="MyImage">
</a>

<script>
function ActivateImage(ImageName)
{
document.images(ImageName).src = "Image2.gif"
}

function InactivateImage(ImageName)
{
document.images(ImageName).src = "Image1.gif"
}
</script>


I have about 20 images setup in the similar way on my
page.

The problem is that when the page is loading, it seems
that only the images that are specified in my HTML are
loaded. The other images start loading as I move mouse
over original images. So, since it takes a whlie for those
alternate images to load, the very first time I move mouse
over an image and then quickly move it away the switch
doesn't happen.

Is there any way to make sure that my alternate images get
loaded with my page right away? Or should I use a
different approach all together?

Thanks a lot for any help.

Joe Gass
11/17/2003 9:22:26 AM
You need to use javascript for this, I personally use Macromedia Dreamweaver
to set this kind of thing up
Try a search on google for "preloading images"

[quoted text, click to view]

Munsifali Rashid
11/17/2003 12:45:51 PM
You need to use JavaScript to preload the images. However, preloading
images is sometimes ignored if a user has changed their browser's settings.
The safest way to do this, is to load all the images into two or more
layers, and then show/hide the layers accordingly.

Mun




[quoted text, click to view]

Vic
11/17/2003 1:51:09 PM
Thanks.

VR

[quoted text, click to view]

Vic
11/17/2003 1:52:02 PM
Do you have by any chance any links/samples of using layers?

Thanks for your help.

VR

[quoted text, click to view]

AddThis Social Bookmark Button