jQuery URL Parser v2.0
A jQuery plugin to parse urls and provide easy access to their attributes (such as the protocol, host, port etc), path segments, querystring parameters, fragment parameters and more.
Specifying the URL to parse
There are a few different ways to choose what URL to parse:
var url = $.url(); // parse the current page URL var url = $.url('http://allmarkedup.com'); // pass in a URI as a string and parse that var url = $('#myElement').url(); // extract the URL from the selected element and parse that - will work on any element with a `src`, `href` or `action` attribute.
URL attributes
The .attr()
method is used to return information on various parts of the URL. For example:
var url = $.url('http://allmarkedup.com/folder/dir/index.html?item=value'); url.attr('protocol'); // returns 'http' url.attr('path'); // returns '/folder/dir/index.html'