HELP! * YELLOW=global GREY=local Global HTML version of Foils prepared 21 February 97

Foil 32 The String Object in JavaScript - I

From Feb 17/19 Delivered Lecture for Course CPS616 -- aJavaScript Language Objects and Frames CPS616 spring 1997 -- Feb 17 and 19 1997. by Geoffrey Fox * Important Information in IMAGE
Secs 66.2
Any constant such as "Hello World!" or variable holding text is a string object in JavaScript -- here is the first example
/* Add stem to newurl if latter is a relative address */
/* stem must end with a slash */
function checkurl(stem,newurl) {
  • var len = newurl.length; // length Property of string object
  • var stemlen = stem.length;
  • if( len < 7 ) {
    • return (stem + newurl); } // Input was not absolute
  • var grab = newurl.substring(0,6); // Get first six characters
  • if( (grab == "ftp://") || (grab == "http:/") )
    • return newurl; // input was definitely absolute
  • return (stem + newurl);
}
function seturl(name) {
name.href = checkurl("http://www.npac.syr.edu/users/gcf/wisdom/","List.html");
}


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 Fri Feb 21 1997