...

View Full Version : How do I KNOW that preloading really works?



Tails
04-03-2003, 09:20 PM
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.

cg9com
04-03-2003, 10:00 PM
you have a thread with the same topic already? :)
http://www.codingforums.com/showthread.php?s=&threadid=15557

Tails
04-03-2003, 10:32 PM
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?

cg9com
04-04-2003, 03:11 AM
everything *looks* fine to me, it loaded with the page. IE6
took no time to load.

Tails
04-04-2003, 09:15 PM
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.

brothercake
04-04-2003, 09:34 PM
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)


var imgs = new Array;
for(var i=0; i<5; i++)
{
imgs[i] = new Image;
imgs[i].src = "pics/picture" + i + ".gif";
}

cg9com
04-04-2003, 10:13 PM
or you can click "search" on the top right of every page, you can search for user names etc. :D

Tails
04-12-2003, 09:38 PM
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?

cg9com
04-13-2003, 06:53 AM
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. :confused:

HairyTeeth
04-13-2003, 11:55 AM
You can use the onload and onerror event handlers.

http://www.codingforums.com/showthread.php?s=&threadid=8383

Tails
04-15-2003, 09:29 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum