hi guys, i have like
http://www.mydomain.com/hello/you
with top.location.host, i can get "http://www.mydomain.com"
with window.location.href i can get "http://www.mydomain.com/hello/you"
is there a chance to get just "/hello/you" ???
hi guys, i have like
http://www.mydomain.com/hello/you
with top.location.host, i can get "http://www.mydomain.com"
with window.location.href i can get "http://www.mydomain.com/hello/you"
is there a chance to get just "/hello/you" ???
location.pathname
pathname will only return the path. If you want the querystring and optionally hash, you would need to combine the search and hash properties as well. 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 the entire thing,
/path/to/glory?key=value&world=cup#part/of/page
then just concatenate all these:
location.pathname + location.search + location.hash
Always wanted to use with somewhere. This looks like the perfect opportunity :)
with(location) {
pathname + search + hash;
}