Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Oct 2005
    Location
    Cape Town
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Image preload and image switch fails in IE6

    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

  • #2
    Regular Coder
    Join Date
    Aug 2005
    Posts
    282
    Thanks
    0
    Thanked 0 Times in 0 Posts
    May help?
    Code:
    <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>

  • #3
    gph
    gph is offline
    Regular Coder
    Join Date
    Apr 2005
    Posts
    161
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by zfred
    How do I get IE6 to use the cache
    This is a known bug in IE6.

  • #4
    New to the CF scene
    Join Date
    Oct 2005
    Location
    Cape Town
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    KC-Luck: Thank you for the code

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

  • #5
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,468
    Thanks
    3
    Thanked 495 Times in 482 Posts
    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

  • #6
    Regular Coder
    Join Date
    Aug 2005
    Posts
    282
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •