如何使用 Javascript 打开 Windows 资源管理器 (Windows+E)
如何通过Javascript打开Windows资源管理器(Windows+E)?
How do you open Windows Explorer (Windows+E) through Javascript?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您无法通过 JavaScript 打开 Windows 资源管理器,因为现代 Web 浏览器已被锁定,对客户端用户的硬盘驱动器的访问几乎为零。未修补的 Internet Explorer 6.0 版本可以通过在新窗口中浏览
file://c:/
来访问 Windows Explorer。You cannot open Windows Explorer through JavaScript because modern web browsers are locked down to offer virtually zero access to the client user's hard drive. An unpatched version of Internet Explorer 6.0 could have accessed Windows Explorer by browsing in a new window to
file://c:/
.window.open 不适用于现代浏览器上的本地路径或网络路径,您需要将路径转换为 URL,如 c:\data 到 file:///C:/Data/ 或者您可以使用 HTML5 功能,如下所示
另一种方法在网络浏览器中打开的文件夹是:
mypc:您的计算机名称
myfolder:您要打开的文件夹
window.open wont work for local path or network path on modern browsers, you need to turn your path to URL like c:\data to file:///C:/Data/ or you can use HTML5 feature like below
Another way to open folder in web browser is:
mypc: your computer name
myfolder: folder you want to open
实现这一目标的唯一方法是在客户端操作系统中注册自定义协议处理程序。
之后,与该协议相关的任何链接都将被发送到处理程序,该处理程序将打开所需的应用程序。在我们的例子中是 Windows 资源管理器。
一般来说,它应该充当在 BitTorrent 客户端中打开的“磁铁:”链接。
或者像在邮件应用程序中打开的“mailto:”链接。
如何在 Windows 中注册协议处理程序,您可以在这里找到:
注册自定义处理程序@ Microsoft
但要小心,让 Windows 资源管理器在不进行任何过滤的情况下打开来自网络的链接并不是很安全。强烈建议编写单独的处理程序来处理链接,过滤掉所有危险部分,然后将就绪链接传递给操作系统。
因此,毕竟您可以制作每个客户端都必须安装才能工作的安装包,如果该解决方案适用于来自内部网的人员,但不适用于互联网上的陌生人,那么一切都很好。
Only way to achieve that is to register custom protocol handler in client's operating system.
After that, any link related to that protocol would be sent to handler which would open desired application. In our case Windows Explorer.
Generally it supposed to work as "magnet:" links that are opening in BitTorrent clients.
Or like "mailto:" links that are opening in Mail applications.
How to register protocol handler in Windows you can find here:
Register Custom Handler @ Microsoft
But be careful, letting Windows Explorer to open links from the network without any filtering is not very safe. It's strongly recommended to write separate handler program that will process link, filter out all danger parts, and than pass ready link to the OS.
So after all you can make installation package that every client would have to install to make it work, and everything is great if that solution is for fellows from intranet, but not for strangers in Internet.