Assuming you have this url : http://www.domain.com////// . How is possible to change the uri path , by seting only the relative path (window.location = 'home') not the absolute one ( window.location = 'http://www.domain.com/home') . If you assing to location.href a relative path , the above url would be www.domain.com/////home . I want www.domain.com/home
Asked
Active
Viewed 1,013 times
0
-
1It appears you want your links to be relative to the root. You should find an answer in this post http://stackoverflow.com/questions/5559578/havling-links-relative-to-root – Jacob Tomlinson Sep 17 '12 at 10:22
-
@Jacob yea, true . Idk why i had the ideea the browsers will set the root w/o the seting the initial "/" . – Tudor Sep 17 '12 at 10:30
1 Answers
3
Try this:
location.href = "/home"
Setting the URL to a string starting with "/" goes back to the "root" level, so right after the host address. Using "../" you can go back single levels, like navigating through a filesystem.

Wutz
- 2,246
- 13
- 15