Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File URI link to local folder in IE7 not working

No matter what I do I cannot get either of these local File URIs:

<a href="file:///c:/">x</a>
<a href="file:///C:">x</a>
<a href="file:///C:\">x</a>
<a href="file://C:">x</a>
<a href="file:///C|/">x</a>
<a href="file:///C|">x</a>
<a href="C:\">x</a>
<a href="C:">x</a>
<a href="#" onclick="return window.open('c:\\');">#</a>

...to work. I've tried putting the site in different zones (Local Intranet, Trusted Sites), turning on/off Protected Mode and fiddling with the security settings for the active zone. I've also tried many variations of the URI. But when I click the links, nothing happens. No errors either.

The only working scenario is when the HTML file is opened from a file:/// location and has file:/// links in it. Obviously, this is no great help.

Is there a workaround of some kind? There seems to be alot of contradictory information on the web about this.

like image 665
Kakmonstret Avatar asked May 25 '10 12:05

Kakmonstret


1 Answers

Your file urls are malformed. It should be:

file:///c:/folder/

Please refer to The Bizarre and Unhappy Story of File URLs.

This works for me:

<html>
 <head></head>
 <body>
  <a href="file:///c:/">link</a>
 </body>
</html>

When you click Link, a new Windows Explorer window is opened to the specified location. But as you point out, this only works from a file:// URL to begin with.

A detailed explanation of what is going on can be found here. Basically this behavior by design for IE since IE6 SP1/SP2 and the only way you can change it is by explicitly disabling certain security policies using registry settings on the local machine.

So if you're an IT admin and you want to deploy this for your internal corporate LAN, this might be possible (though inadvisable). If you're doing this on some generic, public-facing website, it seems impossible.

like image 66
i_am_jorf Avatar answered Sep 22 '22 16:09

i_am_jorf