Absolute file urls in html?


I have no idea where this question should go, so here it is.

I have a script that generates absolute file URLS as hrefs in an html file.

If I click on the link, it treats it as relative and prepends the current path to the URL.

If I inspect the link, sure enough, the browser has added a dot to the front.

However, if I view source, the dot isn’t there and the link works as expected when clicked on.

This also happens in chrome, so I expect it’s some kind of same origin policy.

Is there a way of disabling or working around this behaviour? It’s extremely annoying, as my links span more than one disk.

No, I’m not going to run an http server to access the file for me. :slight_smile:

Best wishes,

An “absolute” href has a scheme. If you have an absolute file -path- that starts with a slash, that will always look like a relative URL to the HTML parser. You need to put file:// in front of your operating system absolute file path. Like file:///usr/local/somefile.txt (3 slashes total in front).

file:// urls can only be opened from other local file documents. Web pages loaded from an http: or https: url aren’t allowed to load these for security reasons.