Host.js
Get some information about the host.
Install
bower install host.js$host
Host.js exposes an object called $host that contains some methods. You can see the methods available through the options method.
$host.url()
Assuming that we are in www.example.com
without parameter it get the URL
$host.url();
/* http://example.com */with parameter it navigates to another address
$host.url("http://foo.com");or
$host.url("/foo");$host.protocol()
Get the protocol being used
$host.protocol();or set the protocol
$host.protocol("https");$host.params()
Get the parameters passed
$host.params();
/* http://example.com?foo=foo&bar='bar' */Will return a object like this:
{ foo: 'foo', bar: 'bar' }or set the params
$host.params({ name: 'John' });
/* http://example.com?name=John */$host.reloadPage()
Reload the page
$host.reload();$host.hash()
Get the URL hash
$host.hash();
/* http://example.com#foo*/Will return a string like this:
"#foo"or set the hash
$host.hash("#bar");
/* http://example.com#bar*/$host.options()
Shows the options
$host.options();Will return something like this
url() protocol() hash() addHash() params() reloadPage() options()