Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.0k views
in Technique[技术] by (71.8m points)

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...