Basic HTML version of Foils prepared 23 June 1997

Foil 40 JavaScript String Objects - I

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


Any constant such as "Hello World!" or a variable holding text is a String object in JavaScript. For example:
/* Add stem to newurl if the latter is a relative
address. Stem must end with a slash. */
function checkurl(stem, newurl) {
var len = newurl.length; // length property of String
var stemlen = stem.length;
if ( len < 7 )
  • return (stem + newurl); // URL is not absolute
var grab = newurl.substring(0,6); // first six chars
if( (grab == "ftp://") || (grab == "http:/") )
  • return newurl; // URL IS absolute!
return (stem + newurl);
}
function seturl(name) {
var addr = "http://www.npac.syr.edu/users/gcf/wisdom/";
name.href = checkurl(addr, "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 Apr 1 1998