1

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.

Ilya Gazman
  • 31,250
  • 24
  • 137
  • 216
  • 2
    Its something wrong with permissions in the browser... its so the browser cant be used to attack your machine. – craig1231 Feb 04 '12 at 15:52
  • When you say "working", what file is this link in? Is it one that's on your local machine or one on a website? – bouteillebleu Feb 04 '12 at 15:53
  • @bouteillebleu on my local machine. if I copy path this link to my browser than it works just fine – Ilya Gazman Feb 04 '12 at 15:55
  • You can work around it by saving this HTML file local and viewing it local, but it will never work from any domain other than file://// – AlexC Feb 04 '12 at 16:02

2 Answers2

2

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

Community
  • 1
  • 1
AlexC
  • 1,091
  • 13
  • 25
0

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”.

Panshul
  • 956
  • 1
  • 10
  • 25