location.pathname
pathname will return the path only. If you want a querystring and optionally hash , you will need to combine the search and hash properties. Consider this URL:
http://www.example.com/path/to/glory?key=value&world=cup#part/of/page location.pathname => "/path/to/glory" location.search => "?key=value&world=cup" location.hash => "#part/of/page"
If you want everything
/path/to/glory?key=value&world=cup#part/of/page
then just put it all together:
location.pathname + location.search + location.hash
Always wanted to use with somewhere. It looks like a great opportunity :)
with(location) { pathname + search + hash; }
Anurag
source share