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