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 3 of 3
  1. #1
    New Coder
    Join Date
    Jan 2005
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Halt & Resume a Script Depending on Return Value

    Can someone tell me how to halt the execution of a script if a certain thing does NOT happen, and have the script continue if this certain thing DOES happen? Below is an improvised line of code:

    document.firstImage.src = "LIC-1.bmp"; onLoad="returnValue(); if return true;" {proceed=true} else {proceed=false}

    Before you respond please note that I AM NOT looking for an image preloading script! I've posted this question before on several forums and got back a dozen such complete scripts. Yes, the main element of the script I'm trying to make is the loading of an image, but I'm only interested in making the script either halt or proceed based on the complete downloading of a given image. I'm just a "cut & paster" but any regular Javascripter can see what I'm trying to do here:

    The page begins to load and the script calls for a certain picture to start comming down the wire. The onLoad tells that something has to be attended to once the entire picture file is in the browser cache and that this "something" will have a returnValue. Once the browser gets to the part of the script where it says, "proceed or not," not only does the script wait to see what happens but any parts in the document body (that are named/identified in the script) will also wait, or otherwise behave as dictated in the script. While the image is downloading, it's returnValue is "false" -- as long as this is false, the script will not advance to the command in the next line ("proceed=false"). Once the image is completely in the browser cache, the returnValue becomes "true," and when "true" then "proceed=true" (go to the next line in the script). What is the correct syntax for this line?

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    <tag onevent ="return somefunction()"/>
    ...

    function somefunction(){
    if(certain thing NOT happend){
    return false;
    }
    else{
    ...
    continue the rest of the code lines
    ...
    }
    }
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts


  •  

    Posting Permissions

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