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