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
Join the weekly newsletter
Sign up for our newsletter. You'll be updated on new tutorials as they come available.
Subscribe today and get a 50% discount code to Paulund