views:

240

answers:

1

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.

+1  A: 

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.

jeffamaphone
Sorry, I've tried that as well (see my updated question). Also, I was wrong about it working in other browsers, mysteriously; I was sure it worked in IE8 and IE6 on Windows 7, but I can't reproduce. Very weird.
Kakmonstret
What do you expect to happen when you do this? IE doesn't support hosting shellviews as of IE7.
jeffamaphone
I don't know what *hosting shellviews* means. All I really want is for Explorer to open in a certain folder when a user clicks a link. I know this was possible in the good old days.
Kakmonstret
Windows Explorer can display views of the filesystem. Internet Explorer cannot. If you're hoping for IE to spawn a new Explorer window, that can be done. If you're hoping for IE to show it in the IE frame, that won't work.
jeffamaphone
I'm looking for IE to spawn an Explorer window, yes. How can it be done? No configuration has made it work for me - *except opening the HTML file from a file:/// location*, which obviously would never work in a real-life scenario. In **your answer**, from whence are you opening your HTML file, and what combination of Windows and IE are you using?
Kakmonstret
Ah, I was opening it from a file URL. Let me try something.
jeffamaphone
I've updated my answer.
jeffamaphone
Thanks, very interesting. I'm building an Intranet (*Local Intranet* zone for its users) which sort of relied on this functionality and didn't bother to check whether it was still working. :)
Kakmonstret