Display Frame

Not knowing in what order the frames would load, JavaScript pauses until the parent frame says that the data frame is loaded up. Then JavaScript grabs the keyword from the data frame above and transfers it to the box below. The keyword from the data frame above is:

Since no document.write() calls are involved in this display frame, JavaScript can just pause until the data frame is loaded and then grab the data. Here's how we set up the pause until the data frame is loaded. If you'll notice in the parent frameset (default.htm), there is a variable initialized to false:

var data_frame_loaded = false;

That variable stays false until the data frame loads up and changes it to true. So in this display frame, using the grab_val() function, simply checks the data_frame_loaded variable to see if the data frame is loaded yet. If it is, then it grabs the info from the data frame. If not, then it calls setTimeout("grab_val()", 1000) which pauses for one second and checks the data_frame_loaded variable again.

At any given moment, the child frame cannot be sure that the other child frame has loaded yet, so it must check with the parent frame first. That's the strategy behind this prototype script.