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");
|
}
|