jQuery.mobile.path.parseUrl( Url )Returns: Object
Description: Utility method for parsing a URL and its relative variants into an object that makes accessing the components of the URL easy.
Utility method for parsing a URL and its relative variants into an object that makes accessing the components of the URL easy. When parsing relative variants, the resulting object will contain empty string values for missing components (like protocol, host, etc). Also, when parsing URLs that have no authority, such as tel: urls, the pathname property of the object will contain the data after the protocol/scheme colon.
This function returns an object that contains the various components of the URL as strings. The properties on the object mimic the browser's location object:
- The fragment component of the URL, including the leading '#' character.
- The host and port number of the URL.
- The name of the host within the URL.
- The original URL that was parsed.
- The path of the file or directory referenced by the URL.
- The port specified within the URL. Most URLs rely on the default port for the protocol used, so this may be an empty string most of the time.
- The protocol for the URL including the trailing ':' character.
- The query component of the URL including the leading '?' character.
But it also contains additional properties that provide access to additional components as well as some common forms of the URL developers access:
- The username, password, and host components of the URL
- The directory component of the pathname, minus any filename.
- The protocol and authority components of the URL.
- The filename within the pathname component, minus the directory.
- The original URL minus the fragment (hash) components.
- The original URL minus the query (search) and fragment (hash) components.
- The password contained within the authority component.
- The username contained within the authority component.
Various uses of jQuery.mobile.path.parseUrl