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 6 of 6
  1. #1
    New Coder
    Join Date
    Jun 2004
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    script works once data is finish loading

    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.

  • #2
    Senior Coder
    Join Date
    Feb 2004
    Posts
    1,206
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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:
    Code:
    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,
    Sadiq.

  • #3
    New Coder hedbanger's Avatar
    Join Date
    Jun 2002
    Location
    vallejo, ca
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts
    are you preloading your images?
    also try making your images smaller in filesize.
    jf~ if you're not part of the solution, you're part of the precipitate.

  • #4
    New Coder
    Join Date
    Mar 2004
    Posts
    91
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #5
    New Coder
    Join Date
    Jun 2004
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!

  • #6
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Why don't you copy the necassary images/scripts to your server?


  •  

    Posting Permissions

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