如何从 Javascript 打开 Windows 资源管理器窗口?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14119642/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 15:46:35  来源:igfitidea点击:

How can I open a Windows Explorer window from Javascript?

javascriptwindowswindows-explorer

提问by Alihamra

I own a local PHP point of Sale, using wampp as my web-server (Win7). What I'm looking for is to find a way to open the Flash Drive E as we normally do by visiting My Computer - > USB Flash E: ... but using Javascript.

我拥有一个本地 PHP 销售点,使用 wampp 作为我的网络服务器 (Win7)。我正在寻找的是找到一种方法来打开闪存驱动器 E,就像我们通常通过访问我的电脑-> USB 闪存 E:...但使用 Javascript。

I have found this code, which works perfectly as needed...But this only works on IE, I'm using Google chrome as my POS browser but what chrome does..Opens up a blank window !

我找到了这段代码,它可以根据需要完美运行……但这仅适用于 IE,我使用 Google chrome 作为我的 POS 浏览器,但 chrome 的作用是什么……打开一个空白窗口!

Here is the code :

这是代码:

<script>
function CallMe()
{
 window.open("file://PCNAME/E$");
}
</script>
<html>
<input  type="button" onClick="CallMe()" value="Open USB" />
</html>

Is there an alternative way to open USB Drive E? Maybe by using PHP?

有没有其他方法可以打开 USB Drive E?也许通过使用PHP?

回答by Brian Ustas

You could allow the user to navigate their filesystem from the browser using:

您可以允许用户使用以下方法从浏览器导航他们的文件系统:

<input type="file" />?

You can't specify a default location nor can the browser open it automatically, however.

但是,您不能指定默认位置,浏览器也不能自动打开它。

回答by ZooZ

window.open("file:///" + yourLocalOrNetworkPath);

window.open("file:///" + yourLocalOrNetworkPath);