Get URL and URL Parts in JavaScript


window.location.protocol = "http:"
window.location.host = "css-tricks.com"
window.location.pathname = "example/index.html"

http://css-tricks.com/snippets/javascript/get-url-and-url-parts-in-javascript/