Click to See Complete Forum and Search --> : Preloading Images


mbrovage
01-31-2003, 11:35 PM
I am preloading images because I want them there when the viewer gets to the section.

How do I know that they are preloading?


I use this format in the head to preload:

pic2 = new Image(150,129);
pic2.src = "http://www.xxxx.org/~xxxx/DBernie.jpg";


I use this format in the body to call the pic:

<img src="http://www.xxxxx.org/~xxxx/DBernie.jpg" width="150" height="129" border="0" ALIGN=left>


Thanks.

jdavia
02-01-2003, 01:30 AM
I am preloading images because I want them there when the viewer gets to the section.
I use this"
<script language= "Javascript1.1">
img1 = new Image ();
img1.src = "001.jpg";
</script>
How do I know that they are preloading?
By the amount of time they show in the window. Try it with the code and without the code. Or in IE you can see it on the status bar. I am almost sure that they load in the order that they are coded. So load your largest ones first.

You can even load images in the page before the one that they are in, with zero sizes so the imprint of them is there before the page even opens. You won't see them.

<img src="DBernie.jpg"width="0"height="0"border="0">

But don't use this if the page already has many images.

Vamsee Krishna
02-01-2003, 07:54 AM
Originally posted by mbrovage
I am preloading images because I want them there when the viewer gets to the section.

How do I know that they are preloading?


I use this format in the head to preload:

pic2 = new Image(150,129);
pic2.src = "http://www.xxxx.org/~xxxx/DBernie.jpg";


I use this format in the body to call the pic:

<img src="http://www.xxxxx.org/~xxxx/DBernie.jpg" width="150" height="129" border="0" ALIGN=left>


Thanks.

I think this code should help u...i'm using images 1.jpg,2.jpg,.... for my convenience..
----------------------------------------------------------------------
function count_images()
{
if(++num_loaded_images == 7)
animate();
}
var num_loaded_images = 0;
var frame=0;
var images1 = new Array(7);
{
for(i=0;i<7;i++)
{
images1[i] = new Image();
images1[i].onload = count_images;
images1[i].src = "./" + i + ".jpg";
}

}
function animate()
{
document.images.baba.src = images1[frame].src;
frame = (frame+1)%7;
setTimeout("animate()",2500);
}
----------------------------------------------------------------------
Here, I'm animating with images...the images change every 2500 ms but you can fulfill you requirements...hope this helps

bye
Vamsee

Vamsee Krishna
02-01-2003, 07:57 AM
Originally posted by mbrovage
I am preloading images because I want them there when the viewer gets to the section.

How do I know that they are preloading?


I use this format in the head to preload:

pic2 = new Image(150,129);
pic2.src = "http://www.xxxx.org/~xxxx/DBernie.jpg";


I use this format in the body to call the pic:

<img src="http://www.xxxxx.org/~xxxx/DBernie.jpg" width="150" height="129" border="0" ALIGN=left>


Thanks.

I think this code should help u...i'm using images 1.jpg,2.jpg,.... for my convenience..
----------------------------------------------------------------------
function count_images()
{
if(++num_loaded_images == 7)
animate();
}
var num_loaded_images = 0;
var frame=0;
var images1 = new Array(7);
{
for(i=0;i<7;i++)
{
images1[i] = new Image();
images1[i].onload = count_images;
images1[i].src = "./" + i + ".jpg";
}

}
function animate()
{
document.images.IMGName.src = images1[frame].src;
frame = (frame+1)%7;
setTimeout("animate()",2500);
}
----------------------------------------------------------------------
Here, I'm animating with images...the main image name is IMGName...the images change every 2500 ms but you can fulfill you requirements...btw, i'm not checking for any unloaded images here...hope this helps

bye
Vamsee