...

View Full Version : Image preload and image switch fails in IE6



zfred
10-18-2005, 05:34 PM
I have the following code in an html file:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Image Object</title>

<script type="text/javascript">

var idiimages=new Array();
var whichimage=0;
var slideshowspeed=2000;

function Preload()
{
alert("Preload");
if (document.images)
{
alert("Image load");
idiimages["ar1"]=new Image(31,23);
idiimages["ar1"].src="Arw1.GIF";
idiimages["ar2"]=new Image(31,23);
idiimages["ar2"].src="Arw2.GIF";
idiimages["ar5"]=new Image(31,23);
idiimages["ar5"].src="Arw5.GIF";
idiimages["ar6"]=new Image(31,23);
idiimages["ar6"].src="Arw6.GIF";
}
}

function NextSlide()
{
if (whichimage==0)
{
document.myImg.src=idiimages["ar1"].src;
}
if (whichimage==1)
{
document.myImg.src=idiimages["ar2"].src;
}
if (whichimage==2)
{
document.myImg.src=idiimages["ar5"].src;
}
if (whichimage==3)
{
document.myImg.src=idiimages["ar6"].src;
}


if (whichimage<3)
whichimage++;
else
whichimage=0;
setTimeout("NextSlide()",slideshowspeed);
}
</script>

</head>


<body>

<script type="text/javascript">
Preload();
</script>

<img name="myImg" id="myImg" src="Arw1.GIF">

<script type="text/javascript">

NextSlide();

</script>

</body>

</html>

When this is run on NN7 it operates correctly out of the cache but in IE6 it keeps loading the image files off the source machine.

My test consists of renaming the image - IE6 does not display the image (only the place holder) and NN7 keeps going.

How do I get IE6 to use the cache.

Thanks

KC-Luck
10-18-2005, 09:01 PM
May help?

<html>
<head>
<title>Image Object</title>
<script type="text/javascript">
var slideshow = new Array("Arw1.GIF", "Arw2.GIF", "Arw5.GIF", "Arw6.GIF");
slideshow.index = -1;
slideshow.speed = 2000;

function preload() {
if (document.images)
for (var i = 0; i < slideshow.length; i++)
(new Image).src = slideshow[i];
}

function nextSlide() {
if (++slideshow.index >= slideshow.length) slideshow.index = 0;
document.getElementById("slideshow-image").alt =
document.getElementById("slideshow-image").src = slideshow[slideshow.index];
setTimeout(nextSlide, slideshow.speed);
}

preload();
</script>
</head>
<body onload="nextSlide()">
<img id="slideshow-image" src="Arw1.GIF">
</body>
</html>

gph
10-19-2005, 12:08 AM
How do I get IE6 to use the cache

This is a known bug in IE6.

zfred
10-19-2005, 10:03 AM
KC-Luck: Thank you for the code

gph: Thank you for the information - I feared that it might be something like that.

vwphillips
10-19-2005, 11:47 AM
If you are realy concerned about this

Images can be stacked on top of each other and the zIndex changed for the side show effect.

Have thecode if reqd

KC-Luck
10-19-2005, 04:49 PM
one other note, you can dupe IE, and set the img.src = null or "" before you then set it to another src, has worked for co-workers in past!..
g'luck



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum