Ilya Gazman
Ilya Gazman

Reputation: 32226

local link in HTML

This is HTML link to google:

<a href="http://www.google.com/">Google</a>

And it work fine

This is a link to my local file:

<a href="file:///C:/myhtml.html">Local</a>

And its not working, why?

If this is some sort of security issue, so how can I work around it? It's just for my own testing.

Upvotes: 1

Views: 5572

Answers (2)

Panshul
Panshul

Reputation: 956

Due to Mozilla’s security model(as well as other modern browsers too), file://-links to local files on your computer or files on a network share do not work on (non-local) web pages; a click on such a link just does nothing. Links to local files could be useful on intranet sites like wikis.

There's an extension named LocalLink(http://locallink.mozdev.org/) for FireFox (and Thunderbird), that adds a new entry “Open Link in Local Context” to the link’s context menu. After you have installed the extension from https://addons.mozilla.org/firefox/addon/281 , you can open file://-links by right click on the link and select “Open Link in Local Context > Current Window”.

Upvotes: 0

AlexC
AlexC

Reputation: 1141

This sort of link to a local file will work in some browsers as long as the HTML is also called from a local file. If not, it's a security vulnerability. It won't work at all in webkit based browsers.

See <A>nchor Link to Local File? (<a href='file:///{path}'>DEAD LINK</a> not working in FireFox but in IE)

And Cross-browser link to file on local system

Upvotes: 2

Related Questions