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 11 of 11
  1. #1
    Regular Coder
    Join Date
    Nov 2002
    Posts
    672
    Thanks
    1
    Thanked 1 Time in 1 Post

    How do I KNOW that preloading really works?

    I have the page http://XFox_Prower.tripod.com/games/js/slide/miles that has several tiny images and takes about 10 seconds to load (though the total size is only about 3 kb). And when I reload the page, it wasn't stored in cache. I preloaded the images and nothing is working as it is supposed to. I've tested it on slow connections, tested offline on slow removable media, everything. What is wrong with this?

    bg2=new Image()
    bg2.src="bg2.gif"
    c2=new Image()
    c2.src="c2.gif"
    p20=new Image()
    p20.src="20.gif"
    p21=new Image()
    p21.src="21.gif"
    p22=new Image()
    p22.src="22.gif"
    p24=new Image()
    p24.src="24.gif"
    p25=new Image()
    p25.src="25.gif"
    p26=new Image()
    p26.src="26.gif"
    p27=new Image()
    p27.src="27.gif"
    p28=new Image()
    p28.src="28.gif"
    p29=new Image()
    p29.src="29.gif"
    p2a=new Image()
    p2a.src="2a.gif"
    p2b=new Image()
    p2b.src="2b.gif"
    p2c=new Image()
    p2c.src="2c.gif"
    p2d=new Image()
    p2d.src="2d.gif"
    p2e=new Image()
    p2e.src="2e.gif"
    p2f=new Image()
    p2f.src="2f.gif"
    pa=new Image()
    pa.src="puz2.gif"

    I'd go into arrays and a for loop, but if this won't work, neither would that. I don't know why it isn't working or what is wrong. IE 5.0 and 6.0 throw no error messages at me.

  • #2
    Senior Coder
    Join Date
    Jul 2002
    Posts
    1,628
    Thanks
    0
    Thanked 0 Times in 0 Posts
    you have a thread with the same topic already?
    http://www.codingforums.com/showthre...threadid=15557

  • #3
    Regular Coder
    Join Date
    Nov 2002
    Posts
    672
    Thanks
    1
    Thanked 1 Time in 1 Post
    I did not intend to double post. In fact, I don't even remember that post. But why is this not working? Does the page work for you? Is my script wrong? does IE not support preloading?

  • #4
    Senior Coder
    Join Date
    Jul 2002
    Posts
    1,628
    Thanks
    0
    Thanked 0 Times in 0 Posts
    everything *looks* fine to me, it loaded with the page. IE6
    took no time to load.

  • #5
    Regular Coder
    Join Date
    Nov 2002
    Posts
    672
    Thanks
    1
    Thanked 1 Time in 1 Post
    That worked.

    bg2=new Image()
    bg2.src="bg2.gif"



    document.write('<img src="'+bg2.src+'" />')

    So I guess I have to put all my html in javascript writes? I'd like to use a for loop with arrays then. I tried and it didn't work. But I was in such a hurry, I wonder if I had the array full of objects before the objects were created was the reason for the undefined errors.

    Can someone tell me how you can look for posts someone has made? If I knew how to look, I would have made sure I wasn't double posting. And I don't remember those replies to my old post, but I do remember a time when I clicked the links in the notify email and they were links to bad threads.

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by Tails
    Can someone tell me how you can look for posts someone has made?
    If you click someone's "profile" button, then at the top-right of the info table there's a link - "Search for all posts by this user." I often do it on myself.

    (btw - I've closed your other thread, so it can continue in this one. I know you didn't mean it, but please do try not to have multiple threads going on the same question; you can pick a thread up weeks after you originally posted it, there's no time limit on individiual threads)


    Anyway - you can use arrays to preload images; something like this (assuming sequentially numbered images)
    Code:
    var imgs = new Array;
    for(var i=0; i<5; i++)
    {
    	imgs[i] = new Image;
    	imgs[i].src = "pics/picture" + i + ".gif";
    }
    Last edited by brothercake; 04-04-2003 at 08:40 PM.
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #7
    Senior Coder
    Join Date
    Jul 2002
    Posts
    1,628
    Thanks
    0
    Thanked 0 Times in 0 Posts
    or you can click "search" on the top right of every page, you can search for user names etc.

  • #8
    Regular Coder
    Join Date
    Nov 2002
    Posts
    672
    Thanks
    1
    Thanked 1 Time in 1 Post
    Can you check if the preloading works on this page? http://xfox_prower.tripod.com/games/js/slide/miles
    The images are loaded from objects, but they aren't being preloaded. Maybe cache isn't supported on this browser. So can I get a second opinion? Preferably from someone that doesn't own their own planet or satellite, etc and has just a fair connection?

  • #9
    Senior Coder
    Join Date
    Jul 2002
    Posts
    1,628
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by Tails
    ... can I get a second opinion? Preferably from someone that doesn't own their own planet or satellite, etc
    lol, i have a dialup, the page loads first, then images, like normal.

    Moderator: General web building

    Get out from under them, resist and multiply.
    Get out from under precipice and see the sky.

  • #10
    Regular Coder
    Join Date
    Mar 2003
    Posts
    176
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can use the onload and onerror event handlers.

    http://www.codingforums.com/showthre...&threadid=8383

  • #11
    Regular Coder
    Join Date
    Nov 2002
    Posts
    672
    Thanks
    1
    Thanked 1 Time in 1 Post
    Well that's the funny thing. Everything returns as true for all image.complete. But the computers I am testing on don't seem to like cookies and probably don't even know what cache is (Either Windows 2000 is a downgrad or it is disabled). But if you say it works fine, then that's what's important. Hmm, now to work on a progress bar. I have one problem with it. When I click scramble, it shows a load percent between a function. But the real loading time is undetectable because the processor is thrown into a sudden panic which takes about 10 seconds on any modern machine. Take a look. I can't seem to get a variable to refresh with each function load even with a setInterval. I'll mark the details later, the code is quite crammed, and I don't have time at the moment.


  •  

    Posting Permissions

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