问题
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.
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 !
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?
回答1:
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.
回答2:
window.open("file:///" + yourLocalOrNetworkPath);
来源:https://stackoverflow.com/questions/14119642/how-can-i-open-a-windows-explorer-window-from-javascript