Web Analytics Made Easy -
StatCounter Preload images - CodingForum

Announcement

Collapse
No announcement yet.

Preload images

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Preload images

    why doesnt this work?

    <html>
    <head>
    <title>Untitled Document</title>
    <script>
    img1=new Image()
    img1.src="1.bmp"
    img2=new Image()
    img2.src="2.bmp"
    img3=new Image()
    img3.src="3.bmp"
    img4=new Image()
    img4.src="4.bmp"
    img5=new Image()
    img5.src="5.bmp"
    img6=new Image()
    img6.src="6.bmp"
    img7=new Image()
    img7.src="7.bmp"
    img8=new Image()
    img8.src="8.bmp"
    </script>

    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>
    <img src="1.bmp" width="289" height="194"><img src="2.bmp" width="289" height="194">
    <img src="3.bmp" width="289" height="194">
    <img src="4.bmp" width="289" height="194">
    <img src="5.bmp" width="289" height="194">
    <img src="6.bmp" width="289" height="194">
    <img src="7.bmp" width="289" height="194">
    <img src="8.bmp" width="289" height="194">
    </body>
    </html>

    thanks alot,

    and alos how could i display how much there is left to download and the download rate?

    And is there a way to preload the HTML file as well as the js file


    thanks
    Last edited by JAVAEOC; Feb 13, 2004, 11:26 PM.
    http://www.bluephoenix.uni.cc/

  • #2
    I usualy give the img tags an id and then

    document.getElementById('IMG_ID').src=img1.src.

    example:
    http://www.the-hive.dk/~donp/boxes.html

    I do not know if that the best way to do it but it works.

    Comment


    • #3
      but i want my whole HTML to be white till my pics have loaded and then they all appear at the same time....

      how can i do that?

      thanks
      http://www.bluephoenix.uni.cc/

      Comment


      • #4
        all i can find in the Internet is this:
        var someimage=new Image();
        someimage.src="thesrc"

        thats just how i did it....

        so i used it in the example i posted before where each of the images is a 500 k image (to get a resonable large loading time)...

        well it doesnt work the images are NOT preloaded and they just load one by one

        why?
        http://www.bluephoenix.uni.cc/

        Comment


        • #5
          well the easiest I think is


          1. make a bmp 1x1 white.

          2. put it rigth after body tagget.

          3.stretch it to the full height and width of the document.

          4. use z-index to make it lay over everything.

          5. on onload remove it.

          Comment


          • #6
            sounds good... thanks
            http://www.bluephoenix.uni.cc/

            Comment


            • #7
              Just a little warning to long exposure of a white screen mite get the user to believe the page is unreachable and there by makin him stop the load in some way(refresh,back,cancel)

              Comment


              • #8
                true

                ok ill think bout it

                thanks
                http://www.bluephoenix.uni.cc/

                Comment

                Working...
                X