开发者

HTML local file access

I would like to access a local file in the immediate directory

From my un开发者_如何学JAVAderstanding, 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?


Use:

document.html

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.


If it's running locally (from that directory), just use ./ without the file://.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜