View Full Version : Halt & Resume a Script Depending on Return Value

icon kid
01-20-2005, 01:35 AM
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?

01-20-2005, 09:23 AM
<tag onevent ="return somefunction()"/>

function somefunction(){
if(certain thing NOT happend){
return false;
continue the rest of the code lines

01-20-2005, 03:35 PM
double posted