Skip to content

Instantly share code, notes, and snippets.

@ricardodantas
Created June 17, 2013 22:31
Show Gist options
  • Save ricardodantas/5801084 to your computer and use it in GitHub Desktop.
Save ricardodantas/5801084 to your computer and use it in GitHub Desktop.
Get / parse URL via javascript
// If URL is http://www.somedomain.com/account/search?filter=a#top
window.location.pathname // /account/search
// For reference:
window.location.host // www.somedomain.com (includes port if there is one)
window.location.hostname // www.somedomain.com
window.location.hash // #top
window.location.href // http://www.somedomain.com/account/search?filter=a#top
window.location.port // (empty string)
window.location.protocol // http:
window.location.search // ?filter=a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment