redirect dynamic to parent site

redirect dynamic to parent site


Hi I wanted to create a link that is dynmaic in my site. The name could be 'Go Back', but it should not use go back history, I want the link to get up one level strict according to the nuber of slashes in the URL, e.g. in the structure of sites and pages I got,

For example:
If the I click such link on this page: https://forum.jquery.com/using-jquery/newtopic
(I should be redirected to.. )

Or.. If I'm at this level..

Can we do such stuff with jQuery?

And the same if I should go up 2 levels?

Thanks!