Return previous folder in URL
If my path is "http://www.example.com/folder1/folder2/" how can I return to "http://www.example.com/folder1/"
I've tried
<a href="../">Back</a>
Which get me back to "http://www.example.com/" and not the previous folder. Any clue on how to do it ?
开发者_Go百科EDIT
I have a
<base href="http://www.example.com/" />
in the head, could it be because it try to go down 1 folder from that base ?
<a href="..">Back</a>
Should work if you drop the trailing slash. Don't really know why it wouldn't work with it but if it's not working, try that...
EDIT Just tested and both versions worked for me in IE8 - what browser are you using to test it?
Another Edit
If you use a <base>
tag, all relative hrefs will be relative the href attribute specified as the <base>
(thats the point of it). If your base is the root of the site, like http://www.example.com/
, links that try to step down a directory won't make any sense, since there's nowhere lower to go, and they will just point to the root directory. However, if the base is the root of the site, there's probably no point in having one at all, since this is, effectively, the default - it would only make a difference if you were working from a higher level directory.
If the base is not the root, but somewhere higher (like http://www.example.com/somedirectory/
) there is a point in the base declaration, but you have to make a decision - something would have to be specified absolutely. So if you have done it because you want to refer to all your images as just file.jpg
instead of /somedirectory/file.jpg
, you either need to change your image references to the absolute /somedirectory/file.jpg
, or have your 'navigation links' like the one shown in the question specified absolutely. You can't do both.
I would say (although I don't know much about the rest of your site and how it was built) that your best bet is to scrap the <base>
in order to allow for relative navigation links, but the choice is yours...
精彩评论