href =“" file://"不起作用 [英] href="file://" doesn't work
问题描述
我有一个问题:
href="file://"
好吧,如果我写的像是
I have a problem with:
href="file://"
Well I want to point a link in html to file, in browser if I write like
file:///K:/filename.pdf
它可以打开文件,但是如果我指向它:
It works to open a file, but if I point it to:
href="http://file:///K:/AmberCRO%20SOP/2011-07-05/SOP-SOP-3.0.pdf"
它不起作用.链接更改为:
It doesn't work. link is changed to:
file///K:/AmberCRO%20SOP/2011-07-05/SOP-SOP-3.0.pdf
文件后的colon
消失.关于该怎么做有什么建议吗?
The colon
after file disappears. Any suggestions as to what to do?
推荐答案
将您的URL重写为file///K:/AmberCRO%20SOP/2011-07-05/SOP-SOP-3.0.pdf
的原因是因为您指定了http://file://
The reason your URL is being rewritten to file///K:/AmberCRO%20SOP/2011-07-05/SOP-SOP-3.0.pdf
is because you specified http://file://
开头的http://
是所使用的协议,您的浏览器正在剥离第二个冒号(:),因为它无效.
The http://
at the beginning is the protocol being used, and your browser is stripping out the second colon (:) because it is invalid.
注意
如果您链接到类似的东西
If you link to something like
<a href="file:///K:/yourfile.pdf">yourfile.pdf</a>
上面的内容表示您正在查看URL的计算机上k:驱动器上名为k:/yourfile.pdf
的文件的链接.
The above represents a link to a file called k:/yourfile.pdf
on the k: drive on the machine on which you are viewing the URL.
您可以执行此操作,例如,下面创建了C:\temp\test.pdf
You can do this, for example the below creates a link to C:\temp\test.pdf
<a href="file:///C:/Temp/test.pdf">test.pdf</a>
通过指定file://表示这是本地资源.此资源不在Internet上.
大多数人没有K:/驱动器.
Most people do not have a K:/ drive.
但是,如果这是您要实现的目标,那很好,但这不是网页上典型"链接的工作方式,除非您打算访问每个人,否则您不应该这样做.链接可以访问(相同?)K:/驱动器(共享网络驱动器可能就是这种情况).
But, if this is what you are trying to achieve, that's fine, but this is not how a "typical" link on a web page works, and you shouldn't being doing this unless everyone who is going to access your link has access to the (same?) K:/drive (this might be the case with a shared network drive).
您可以尝试
<a href="file:///K:/AmberCRO-SOP/2011-07-05/SOP-SOP-3.0.pdf">test.pdf</a>
<a href="AmberCRO-SOP/2011-07-05/SOP-SOP-3.0.pdf">test.pdf</a>
<a href="2011-07-05/SOP-SOP-3.0.pdf">test.pdf</a>
请注意,http://file:///K:/AmberCRO%20SOP/2011-07-05/SOP-SOP-3.0.pdf
是格式错误的
这篇关于href =“" file://"不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!