javascript delay
- Started
- Last post
- 7 Responses
- moural
Hi. I have some images that I'd like to load before my script initializes. The script is a (pre)loading bar, but currently it comes up before one of the images which contains text, so it just doesn't look right.
I've tried an "onLoad", but it makes IE freak out, and Firefox appears to load the script on a separate page - all the images load, and then the bar shows up on another page. - quite weird.
Any help is appreciated. Thanks.
- heavyt0
you can try to use SetTimeout to delay the loading. Or you can use DEFER to delay the script load until the page loads.
TR1
- moural0
Thanks, but neither of these work.
Defer gives errors in IE (once I click through them, it still loads on a separate page) and Firefox appears to ignore it completely.
Likewise, SetTimeout only delays the loading of the script, not the order of parsing, so my image still loads after.
- fugged0
you want your images to load before the preloader? doesn't that defeat the purpose? Or are the images for the preloader?
If they are, you can uset the setTimeout to run a script at a set interval to check the status of each of the images. Once it has loaded the images the script can then call the preloader function. (?)
- moural0
No, no. These images are on the same page as the preloader. Only the images on subsequent pages are being preloaded, not these.
The problem is all the images above the script load normally, but the image below loads after (ie. page loads from top to bottom, script being in the middle) the preloader is almost finished.
Like I mentioned, if I use SetTimeout, all this does is delay the loading of the script, only making the bottom image load later. What I need is for the entire page to load before the script, which is why I used onLoad and defer as heavy mentioned. And unfortunately, neither seem to work.
- fugged0
If I understand corerctly which I probably don't, what I said will still work...
here's some psuedo code:
http://www.alien109.com/meh.txtdunno if that will work. haven't tested it. but in theory it should?
- fugged0
is this what you mean?
- moural0
Thanks, I appreciate you drawing that up, fugged.
I know it's hard to understand since it's not online, but what I have is a preload bar in the middle of the page. Above that I have an image and below it I have an image. They're not associated with the preloading; one is a title and the other is some secondary text.
I need the preload bar to wait until both of these images are loaded, otherwise I, or the user, can't read all the text in time because the preloading of subsequent images is nearly done.
I know I can just delay the loading of the next page after the bar is finished, but I'm worried it will look unresponsive, and hence broken to the typical user.