PDA

View Full Version : How do I postpone a preload?


pairustwo
01-29-2003, 04:28 AM
I have a site that has some large rollover images.
Also the navigation of the page depends on several hidden layers.
My problem is that I cannot get navigation system and the <div> layers (both of which are controlled by an external .js page) to load until all of the preloading is done.
I have tried to preload via javascript and the content would not show until all the images had preloaded.
Currently I put all the images in a hidden <div> inside the page at the bottom of the .htm page and still they seem to load first.

Shouldn't the external JavaScript load first, and then the XHTML in the order that it is written in the .htm file?

The site is here (http://www.littlea.info)
Don't mind the spash screen, the preload there is not what I am talking about, this is for the background images not the rollovers.
Thanks,
Pairustwo

ez4me2c3d
01-29-2003, 01:00 PM
the most control you'll have is this way.
create a Jscript function like so somewhere on your page, doesn't matter where.function imgLoader() {
var myImg = new Array("images/lounging.jpg", "images/made.jpg", "images/mugshot.jpg", "images/china.gif", "images/babieswalkers.jpg", "images/dragon.gif", "images/sword.jpg", "images/sittingUp.jpg", "images/stamp.gif", "images/sunset.gif");
for (i = 0; i <= myImg.length; i++) {
tmp = new Image();
tmp.src = myImg[i];
}
}

now you can call the function imgLoader() from anywhere whenever you want to..
example<body onLoad="imgLoader()">

pairustwo
01-29-2003, 01:30 PM
Thanks for putting that together.
My problem is that I want to call the function sometime after the page loads. Doesn't the onload call the function right away?

Is there a way to call the function "afterload" when everything else has finished?

Some sort of timer perhaps? hmm.

pairustwo

Algorithm
01-29-2003, 06:46 PM
This will delay the loader by one second.<body onLoad="setTimeout('imgLoader()', 1000)">

ez4me2c3d
01-30-2003, 12:58 AM
Originally posted by pairustwo
Is there a way to call the function "afterload" when everything else has finished?

onLoad waits until the page has loaded everything else. but if you want to wait longer then use the setimeout method (1000 = 1 sec & 60000 = 1 minute)

whammy
01-30-2003, 01:48 AM
window.onload=setTimeout('myfunction()',3000)

would wait 3 seconds...

P.S. Ew, isn't Ellsworth AFB in Alaska? My brother was stationed there... yech.

Oops, my bad, it's in SD - that's only one state to the north, lol. It was hard to keep track of my bro when he was in the AF for some reasons I probably should not divulge. :D

pairustwo
01-30-2003, 03:25 AM
OK guys, thanks for your help.

When I do this:
<script>
window.onload=setTimeout('imgLoader()',3000);
function imgLoader() {
var myImg = new Array("images/lounging.jpg");
for (i = 0; i <= myImg.length; i++) {
tmp = new Image();
tmp.src = myImg[i];
}
}
</script>
I get an error pointing to line with the with the window.onload
saying: not implemented.
This is in IE6.

Am I setting it up wrong, or is it conflicting with the other function that is called by the onload method? When I click through the error the page works fine.

Pairustwo