====== Browser Extras ======
[[http://www.clientcide.com/docs/Browser/Browser.Extras|docs]]
The CNET libraries have extended the MooTools [[http://www.mootorial.com/wiki/mootorial/01-core/01-browser|Browser Hash]] to include some extra methods that help you manage window properties.
==== .getHost ====
Returns the fully qualified domain of the page. Will also return the host of a url passed to it.
Browser.getHost();
//returns "www.clientcide.com"
Browser.getHost('http://www.example.com/some/path.html');
//returns "www.example.com"
==== .getQueryStringValue ====
Returns the value of a query string key if it's defined. There shouldn't be one defined looking at this page, so for the purposes of this example, click this link before you execute the code below (it'll reload the page with a query string):
reload with a query string
Browser.getQueryStringValue('red');
//returns: apple
You can pass in an optional second argument; a different url. This will return the query string value in that instead of the window location.
Browser.getQueryStringValue('this', 'http://www.example.com?this=that');
//returns: that
==== .getQueryStringValues ====
This returns an object of all the query string values. It takes an optional url as its argument, but defaults to the window location. If you haven't already,
reload with a query string
Browser.getQueryStringValues();
//returns {red: 'apple',yellow:'lemon',green:'lime'}
Browser.getQueryStringValues('http://www.example.com?this=that');
//returns {this:'that'}
==== .qs ====
//Browser.qs// is kind of a shortcut to //Browser.getQueryStringValues()// except that //.qs// is not a function it's the object itself. You can't pass a url to it, so it represents only the values in the window location.
Browser.qs;
//returns {red: 'apple',yellow:'lemon',green:'lime'}
==== .getPort ====
Returns the port of the url as a string, if there is one.
Browser.getPort();
//returns: false
Browser.getPort('http://www.example.com:8001/something.html');
//returns: 8001 (a string)