I am on
www.foo.com
how to call javascript or jquery to navigate to
www.foo.com/site1
or if I am on www.foo.com/site1
to go on
www.foo.com/site1/site2
I am on
www.foo.com
how to call javascript or jquery to navigate to
www.foo.com/site1
or if I am on www.foo.com/site1
to go on
www.foo.com/site1/site2
window.location.href = window.location.href + "/site1"
I suppose this would work.
to get inside site1 from outside
window.location.href="site1/";
to get inside site1/site2 if you are inside site1
window.location.href="site2/";
to get inside site1/site2 directly if you are "outside"
window.location.href="site1/site2/";
to get out of site1 if you are inside site1
window.location.href="../";
to get out of site1/site2 if you are inside site1/site2
window.location.href="../../";
to get out of site1a if you are inside site1a and into site1b (at same level)
window.location.href="../site1b/";
Of course you do not need javascript for this if you use links like <a href="../site1b/">GO</a>
to click.
Using just window.location=.. works too (has even broader support) and even location=.. (you can omit "window.", but I wouldn't do it for clarity and maybe compatibility)
Javascript: Setting location.href versus location
I used all paths with trailing "/", being folders, to avoid automatic redirects from "site1" to "site1/" (slightly slower).