To get the URL protocol use the following snippet.
Returns http / https
To get the URL host name use the following snippet.
To get the URL pathname of the file use the following snippet.
Get URL Hash Value
If a URL has a # target selected this snippet will return the value.
For the URL of http://www.paulund.co.uk#top.
This will return top.
Learn how to code with Treehouse
- Learn projects with access to 1000+ videos
- Practice live with our Code Challenge Engine
- Get help in our members-only forums
- Access 100s of premium tutorials and downloadable content
- Members content consists of premium WordPress plugins
- CSS packages, jQuery packages, tutorial demo files and templates for 100s of web development tutorials
- In-depth development tutorials
- Priority tutorial requests
- No ads