WMLScript URL Standard Library Quick Reference

Preferences - Do not show ads

WMLScript's URL standard library contains a number of functions that help us manipulate URLs.



WMLScript Quick Reference: Functions in the URL Standard Library

escapeString(url)

Replaces special characters in url with the corresponding hexadecimal escape sequence according to the rules of URL escaping.

Example:

var url_str = "http://www.developershome.com/proc.asp?q=" + URL.escapeString("Hello World");

url_str has the string value "http://www.developershome.com/proc.asp?q=Hello%20World".

getBase()

Returns the current WMLScript document's URL without the fragment part (the fragment of a URL is the part that begins with the # character). The URL returned is always in the absolute form.

getFragment(url)

Returns the fragment part of url. The fragment of a URL is the part that begins with the # character.

Example:

var fragment = URL.getFragment("http://www.developershome.com/wmlscript_reference.wml#card1");

fragment has the string value "card1".

getHost(url)

Returns the host part of url.

Example:

var host = URL.getHost("http://www.developershome.com/wmlscript_reference.wml");

host has the string value "www.developershome.com".

getParameters(url)

Returns parameters that exist in url's last path segment.

Example:

var para = URL.getParameters("http://www.developershome.com/wmlscript_reference.wml;1;2;3");

para has the string value "1;2;3".

getPath(url)

Returns the path of url.

Example:

var path_str = URL.getPath("http://www.developershome.com/examples/wmlscript_reference.wml#card1");

path_str has the string value "/examples/wmlscript_reference.wml".

getPort(url)

Returns the port of url.

Example:

var port_num = URL.getPort("http://www.developershome.com:8080/wmlscript_reference.wml");

port_num has the string value "8080".

getQuery(url)

Returns the query part of url.

Example:

var query_str = URL.getQuery("http://www.developershome.com/proc.asp?q1=abc&q2=123");

query_str has the string value "q1=abc&q2=123".

getReferer()

Returns the URL of the referrer. The referrer is the resource that called the current WMLScript document.

getScheme(url)

Returns the scheme part of url. The scheme is the protocol specified in url.

Example:

var scheme = URL.getScheme("http://www.developershome.com/wmlscript_reference.wml");

scheme has the string value "http".

isValid(url)

Checks whether the syntax of url is valid.

Example:

var isURLValid1 = URL.isValid("http://www.developershome.com/");
var isURLValid2 = URL.isValid("<http://www.developershome.com/>");

isURLValid1 has the Boolean value true.
isURLValid2 has the Boolean value false.

loadString(absolute_url, mime_type)

Returns a string that is the contents of the resource located at absolute_url if its MIME type is mime_type. mime_type must begin with "text/".

Example:

var contents = URL.loadString("http://www.developershome.com/wmlscript_reference.wml", "text/vnd.wap.wml");

resolve(base_url, relative_url)

Returns an absolute URL that is formed by embedding relative_url into base_url.

Example:

var url_str = URL.resolve("http://www.developershome.com/", "wmlscript_reference.wml");

url_str has the string value "http://www.developershome.com/wmlscript_reference.wml".

unescapeString(url)

Replaces hexadecimal escape sequences in url with the corresponding character according to the rules of URL unescaping.

Example:

var query_str = URL.unescapeString("q=Hello%20World");

query_str has the string value "q=Hello World".


Preferences - Do not show ads


Page 6 of 6 Previous Page
Contents at a Glance
Print this Web Page | | Back to Top

Feedback Form (Expand)

What do you think about this web page?






Standard WMLScript Libraries Reference - Table of Contents Standard WMLScript Libraries Reference - Contents at a Glance Preferences - Change Color Scheme Preferences - Do Not Show Ads Previous Page