WMLScript » Functions » URL

The URL Library contains fourteen functions designed to manipulate URLs. For example, these functions can be used to return specific information about relative and absolute URLs, handle escape characters, create absolute URLs, and validate a URL syntax.

The syntax of a URL is: scheme://host:port/path;parameters$query#fragment

You can use the following functions to get the various portions of the URL:

Portion Function
scheme getScheme(url)
host getHost(url)
port getPort(url)
path getPath(url)
parameters getParameters(url)
query getQuery(url)
fragment getFragment(url)


The library and function names are case sensitive.

URL.escapeString

Syntax: URL.escapeString(string)

Replaces special characters with hexadecimal escape sequences.

URL.getBase

Syntax: URL.getBase()

Returns an absolute URL.

URL.getFragment

Syntax: URL.getFragment(url)

Returns the fragment portion of the URL.

URL.getHost

Syntax: URL.getHost(url)

Returns the host portion of the URL.

URL.getParameters

Syntax: URL.getParameters(url)

Returns the parameter portion of the URL.

URL.getPath

Syntax: URL.getPath(url)

Returns the path portion of the URL.

URL.getPort

Syntax: URL.getPort(url)

Returns the port portion of the URL.

URL.getQuery

Syntax: URL.getQuery(url)

Returns the query portion of the URL.

URL.getReferer

Syntax: URL.getReferer()

Returns the smallest relative URL.

URL.getScheme

Syntax: URL.getScheme(url)

Returns the scheme portion of the URL.

URL.isValid

Syntax: URL.isValid(URL)

Determines if the syntax of the URL is correct.

URL.loadString

Syntax: URL.loadString(url, contentType)

Returns the content type based upon the provided absolute URL and content type/subtype.

URL.resolve

Syntax: URL.resolve(baseUrl, relativeUrl)

Returns an absolute URL given a base and embedded URL.

URL.unescapeString

Syntax: URL.unescapeString(string)

Replaces hexadecimal escape sequences with the special characters they represent.

See Also: