HELP! * GREY=local LOCAL HTML version of Foils prepared 15 January 1997

Foil 40 The String Object in JavaScript - I

From JavaScript Tutorial for CPS616 Technologies of the Information Age 1997 Basic Information Track of CPS -- Spring Semester 97. by Geoffrey C. Fox * Important Information in IMAGE

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 Wed Feb 19 1997