I'm looking for a neat way of getting the URL of the current document in Javascript.
- The URL should be clean of parameters (?parameter1=bla¶meter2=bla)
- The URL should be clean of hash tags (#jumppoint)
- http/https should be removed/consolidated into http
I know i can get the current URL with location.href and then use some regular expressions to clean it up but maybe there is a nicer/cleaner solution for getting rid of the junk?
This page indicates that you could probably use
window.location.host
to get the part you're actually interested in. I haven't tested it, though.Try: