Html <a href="..."/> 的绝对路径是如何确定的?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10687362/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how is absolute path of <a href="..."/> determined?
提问by prongs
I have an html deep inside my directory structure inside c:\
. one line there is this:
我的目录结构深处有一个 html c:\
。一行是这样的:
<link type="text/css" rel="stylesheet" href="/s/2036/21/2/_/download/superbatch/css/batch.css" media="all">
When I hover over the link, it shows file:///C:/s/2036/21/2/_/download/superbatch/css/batch.css
as the link address. I want it to interpret to actual location which is file:///C:/Users/name/folder1/...some folders/s/2036/21/2/_/download/superbatch/css/batch.css
当我将鼠标悬停在链接上时,它显示file:///C:/s/2036/21/2/_/download/superbatch/css/batch.css
为链接地址。我希望它解释为实际位置file:///C:/Users/name/folder1/...some folders/s/2036/21/2/_/download/superbatch/css/batch.css
What changes are needed to make?
需要做出哪些改变?
EDIT: there are several files containing relative links so I can't just edit each and every of them.
编辑:有几个文件包含相对链接,所以我不能只编辑它们中的每一个。
P.S: please change the title to something better if this one is not expressive enough.
PS:如果这个标题不够表达,请把标题改成更好的。
采纳答案by prongs
finally I had to put the files inside a webserver's htdocs folder. I was kinda hoping for a different solution
最后我不得不将文件放在网络服务器的 htdocs 文件夹中。我有点希望有一个不同的解决方案
回答by Ja?ck
If your HTML file is at C:\Users\name\folder1\...some folders\
, you can just remove the leading slash to make it a relative path.
如果您的 HTML 文件位于C:\Users\name\folder1\...some folders\
,则只需删除前导斜杠即可使其成为相对路径。
Otherwise you have to prefix the address with file:///C:/Users/name/folder1/...some folders
to keep it absolute.
否则,您必须在地址前加上前缀file:///C:/Users/name/folder1/...some folders
以保持绝对地址。
回答by GodLesZ
<link type="text/css" rel="stylesheet" href="./s/2036/21/2/_/download/superbatch/css/batch.css" media="all">
Note the .
(dot) at the begining, which means its a relative path, starting at the current executing directory of the document/the file.
注意.
开头的(点),这意味着它是一个相对路径,从文档/文件的当前执行目录开始。
回答by Royi Namir
First
- I dont see any anchor in your example.
First
- 我在你的例子中没有看到任何锚点。
Second
, it will work only in IE.
Second
,它只能在 IE 中工作。
you have to access the item through UNC
---> \\myShare\lalala
您必须通过UNC
--->访问该项目\\myShare\lalala
here is a working example :
这是一个工作示例:
<a type="text/css" rel="stylesheet" href="\dev-8\c$.txt" >fsdfsd</a>
where dev-8is the name of my computer.
dev-8我的电脑的名字在哪里。
create 1.txt file in your root - and it will work.
在您的根目录中创建 1.txt 文件 - 它将起作用。