URL.getBase
URL.resolve
FUNCTION: URL.isValid
URL.isValid
(URL)
The
URL.isValid
function returns a boolean value that signifies whether the given absolute or relative URL is of the correct syntax for a URL. A
true
is returned if the syntax is correct. A
false
is returned if the syntax is not correct.
The syntax of a URL is:
scheme://host:port/path;parameters$query#fragment
Note that this function does not provide a reason as to why a syntax is invalid. Further, simply because the syntax is of a valid form and a
true
is returned, does not guarantee that the URL address is correct and that the browser can successfully navigate to the site.
The mandatory
url
parameter is any absolute or relative URL that you to wish to test.
Code for IsValidExample.wml
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.WAPforum.org/DTD/wml_1.1.xml">
<wml>
<card id="card1">
<p>
isValid example
</p>
<do type="accept">
<go href="IsValidExample.wmls#findisvalid()" />
</do>
</card>
<card id="card2">
<p>
valid = $(valid)
</p>
</card>
</wml>
Code for IsValidExample.wmls
extern function findisvalid()
{
var testurl = Dialogs.prompt("Enter the URL", "");
var val =
URL.isValid(testurl)
;
WMLBrowser.setVar("valid", val);
WMLBrowser.go("IsValidExample.wml#card2");
};
Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information