How do I link back out of a folder using the a-href tag? [duplicate]

别等时光非礼了梦想. 提交于 2021-01-20 20:08:55

问题


Alright so I have a page in a folder, the page is called jobs.html and the folder is simply called "jobs". Its a sub folder of my mine "website" folder. In the main directory of the "main" folder is my "home.html" file. When I try to do

<a href="home.html">bla</a>

It malfunctions as it is looking for the home file in the jobs folder, which does not exist.

So I ask, how can I reference out of a folder to call a file from the root folder?


回答1:


Try setting your link to be your site root as so; note the / in front of home.html:

<a href="/home.html">bla</a>

Or if you know the path is definitely one directory down then just explicitly tell it to go down 1 directory; note the ../ in front of the home.html.

<a href="../home.html">bla</a>



回答2:


You can move up a directory by using ../ before your html document. So if home.html is up one directory, you could do:

<a href="../home.html">bla</a>


来源:https://stackoverflow.com/questions/20599870/how-do-i-link-back-out-of-a-folder-using-the-a-href-tag

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!