Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何链接相同或不同文件夹中的html页面?_Html_Anchor - Fatal编程技术网

如何链接相同或不同文件夹中的html页面?

如何链接相同或不同文件夹中的html页面?,html,anchor,Html,Anchor,如果html页面位于相同或不同的文件夹中,我如何链接到它们而不写入完整路径?使用相对路径 主页可能是: /index.html 第二页: /otherFolder/otherpage.html 链接是这样的: <a href="/otherFolder/otherpage.html">otherpage</a> 您可以使用 ../ 因此,要从/webroot/site/pages/folder1/myotherpage.htm访问文件夹/webroot/site/pa

如果html页面位于相同或不同的文件夹中,我如何链接到它们而不写入完整路径?

使用相对路径

主页可能是: /index.html

第二页: /otherFolder/otherpage.html

链接是这样的:

<a href="/otherFolder/otherpage.html">otherpage</a>

您可以使用

../
因此,要从/webroot/site/pages/folder1/myotherpage.htm访问文件夹/webroot/site/pages/folder2/mypage.htm,您的链接如下所示:

<a href="../folder2/mypage.htm">Link to My Page</a>

在同一文件夹中,只需使用文件名:

<a href="thefile.html">my link</a>

在父文件夹的目录中:

<a href="../thefile.html">my link</a>
<a href="subdir/thefile.html">my link</a>

在子目录中:

<a href="../thefile.html">my link</a>
<a href="subdir/thefile.html">my link</a>

此外,如果要引用根目录,可以使用:

/
它将引用根。假设我们在一个嵌套在几个级别的文件夹中的文件中,您希望返回到main index.html:

<a href="/index.html">My Index Page</a>


Robert对相对路径做了进一步的解释。

我要提醒你:如果你使用的是绝对路径,那么你的应用程序就不能安装在服务器的“子目录”中


可以工作,但不行

此外,这将进入一个目录,然后返回到另一个子文件夹

<a href = "../subfolder/page.html">link</a>

要进入多个目录,您可以这样做

<a href = "../../page.html">link</a>

从根本上说,我用这个

<a href = "~/page.html">link</a>

如果要链接到根目录,可以使用

../
/
/index.html

如果要链接到同一目录中的文件,只需输入文件名即可

<a href="/employees.html">Employees Click Here</a>
要从根目录链接到employees目录中的索引页,您需要执行以下操作

<a href="../employees/index.html">Employees Directory Index Page</a>

下面的答案是我创建的,用于将另一个共享驱动器的html内容链接到我将发送给管理员的html页面。当然,路径与您的使用有关,但在我的情况下,我只会向他们发送html,从load runner动态更新的所有其他内容都会为我更新。 节省了大量的纸张,而且他们可以根据自己的喜好来处理数字,而不仅仅是一份硬拷贝

SRC="file://///shareddrive/shareddrive-folder/username/scripting/testReport\contents.html" NAME="contents_frame" title="Table of Contents"
使用

例如,如果您的文件位于
folder1
in
folder2
你是这样定位的

../folder1/folder2/image

对于ASP.NET,这在开发和部署方面对我很有用:

<a runat="server" href="~/Subfolder/TargetPage">TargetPage</a>

使用
runat=“server”
href=“~/”
是转到根目录的键

这对被点击的我很有效

简短回答:

用于当前目录

用于上层目录,如shell上的
cd..
命令所示

简单但棘手,我写这个答案主要是为了自己下次不要忘记

ademSite/
├── index.html
└── style.css
index.html
中指向CSS的链接:

在这种情况下,它应该是:

在这种情况下,路径必须是:

这就是asp.net的特点吗?即使这样,您也需要一个服务器端控件(runat=“server”)。再加上Joelange,您就得到了答案。:)什么是超级目录是一个人目录的父目录,什么是子目录是父目录中的目录?@Akshayvijayn是和否。超级目录是“上一级”。子目录为“向下一级”,不确定问题是否与load runner有关:|
├── html
│   └── index.html
└── stylefiles
    └── style.css