2012-02-15 110 views
0

我已经看到了几个<a href=".">link to folder</a>的例子,但我真的不明白它是什么或如何操作它或让它设置文件夹中的特定html页面。 我的网站是一个基本的只有CSS和HTML 它被格式化为更改文件夹索引到文件夹内的HTML页面

[file]home.html // C:/Users/user/Desktop/mywebsite/home.html 
[folder]Order // C:/Users/user/Desktop/mywebsite/order/ 
↳[file]ordersheet.html // C:/Users/user/Desktop/mywebsite/order/ordersheet.html 

我想尝试设置文件夹路径C:/Users/user/Desktop/mywebsite/order/作为文件ordersheet.html C:/Users/user/Desktop/mywebsite/order/ordersheet.html如何才能做到这一点?

回答

0

要设置/orderordersheet.html变化ordersheet.html名称index.html

index.html是默认的文件,该服务器将提供给访问者时,他访问的具体目录。

<a href="/Users/user/Desktop/mywebsite/order/">link text</a> 

link text =你想让它说用户

/Users/user/Desktop/mywebsite/order/什么=目录路径

请记住,这只会在本地工作。如果你有它的服务器上,游客不必访问完整C:/驱动器,所以你必须使用相对链接,即只是/order/

0

如果我remebember正确的,你用这样的:

<a href="file:///C:/Users/user/Desktop/mywebsite/order/ordersheet.html>link to file on harddisk</a> 

如果你想有一个锚到一个文件夹,你只想用这样的:

<a href="file:///C:/Users/user/Desktop/mywebsite/order/>link to a folder on harddisk</a> 
0

您的浏览器是在你的系统的本地文件系统直接操作,所以你不能。

你一直在看的是网络服务器的功能(我会用Apache HTTPD作为例子)。

Web服务器的典型配置会将URI的本地部分映射到本地文件系统上的一个目录,并且只要它们与URI的本地部分匹配就提供这些文件。

如果本地部分解析为目录(而不是文件),那么它会在该目录中查找名称与a list (typically including index.html)匹配的文件并提供该文件。

如果列表中没有任何文件存在,那么它会generate an HTML document containing links to all the files in the directory

由于在浏览器直接读取本地文件系统时没有涉及Web服务器,因此无法将目录映射到索引文件,因此您需要明确地将文件名包含在URI(或开关使用Web服务器)。

相关问题