Basic HTML version of Foils prepared 23 June 1997

Foil 26 Example of a JavaScript Function

From JavaScript Tutorial for Certificate Course UC Web applications Certificate -- Summer 97. by Geoffrey C. Fox, Tom Scavo

Recursion Example
top.setFrame("help.html","mainDisplay");
function setFrame(relativeURL,frameName) {
var actualURL = top.baseURL + relativeURL;
top.frames[frameName].location.href =
    • this.actualURL;
}
top refers to the top-level window in a frameset document. It has a property called frames, which is an array labeled by integers or by name as in <frame> name="frameName" </frame> tag
Setting a URL into the location.href property of a frame loads that page into the given frame
Use this.actualURL to distinguish local variable actualURL from a global variable of the same name
Put these functions in <head> </head> container to ensure they are loaded before anything else



Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Wed Apr 1 1998