View Full Version : script works once data is finish loading

07-01-2004, 01:50 AM
Why is that scripts doesnt work until all the data (images) is finish downloading. Is there a way that script can work when the page hasn't finish downloading all the items yet? I mostly used scripts from dynamik drives.

07-01-2004, 02:17 AM
Well if a script is dependent on an element, an image in your case, and the element is not there yet, the script will fail as it's referring to an element that doesn't exist.

I can't remember if it's an IE-only feature or not, but you can check if a document is finished loading using:

if(document.readyState == "complete") {

In that if statement, you can call your script that will fail if the page has not completed loading.

You may even consider 2 other alternatives:
1. call your script(s) in the onLoad event handler
2. preload your images (if it's only images you're worried about..)

Hope that helps,

07-01-2004, 02:17 AM
are you preloading your images?
also try making your images smaller in filesize.

07-01-2004, 11:17 AM
If you use frames, than you can put some of the code in the onload event handler for one of the frames and it will be called as soon as that frames finished loading (regardless of what is being loaded in other frames)

There is a drawback as you cannot be certain as to the order of frames loading.

07-02-2004, 05:45 PM
Images are not on my server, its a direct http link to another company site, one of the script uses very small 100x100 image and a menu that doesnt uses any images, but either of those scripts will function if everything is not done loading, if it fails to complete downloading the images and such, the script wont work, unless you click the button stop in the IE browser. It all depends on the days, some days it loads very fast and sometimes it doesnt.

My question was simply, if all is not loaded yet, will be good if the scripts works right away even though you dont see all the images loaded, and it will pop once downloaded! :cool:

Willy Duitt
07-02-2004, 05:49 PM
Why don't you copy the necassary images/scripts to your server?

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum