HTML 本地文件访问
我想访问直接目录中的本地文件
根据我的理解,您通常必须执行类似
file://path/to/file/document.html
需要完整路径的操作,但我想做类似的操作
file://./document.html
,其中 ./
代表当前目录引用,这样我就不必知道目录路径,也不必对其做出任何假设。
html 文件路径是否有类似的技巧?
I would like to access a local file in the immediate directory
From my understanding, you'd usually have to do something like
file://path/to/file/document.html
which requires the full path, but I would like to do something like
file://./document.html
instead, where ./
represents the current directory reference, so that I do not have to know the directory path nor make any assumptions about it.
is there any trickery like that possible with html file paths?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用:
如果没有指定协议,也没有目录
/
,浏览器应该从当前页面所在的同一目录/文件夹请求资源。Use:
With no protocol specified, and no
/
for directories, the browser should request the asset from the same directory/folder that the current page is at.如果它在本地运行(从该目录),只需使用
./
而不使用file://
。If it's running locally (from that directory), just use
./
without thefile://
.尝试http://www.nt22.com/html_tutorials/022_html_path.html
使用页面 .html 和 ./page.html 的工作原理相同。
../ 进入下层目录
即
root/www/page.html
如果您在 root/stuff/hi.html 中,您可以通过执行以下操作转到“www”目录
../www/page.html
try this http://www.nt22.com/html_tutorials/022_html_path.html
using page.html and ./page.html works the same.
../ goes to a lower directory
i.e.
root/www/page.html
if you are in root/stuff/hi.html you can go to the 'www' directory by doing
../www/page.html