如何通过js来打开客户端的文件,例如我打开某网站,点击一个button就能在我的机器上打开一个视频文件。
1个回答
2011-02-11
展开全部
<form name="Form1">
<input type="file" name=filename>
<input type=button value="open" onclick="executeCommands()">
<input type=button value="open notepad" onclick="runJSMode('%WINDIR%\\Notepad.exe')">
</form>
<SCRIPT type="text/javascript" LANGUAGE="JavaScript">
function executeCommands(inputParms)
{
var oShell = new ActiveXObject("Shell.Application");
var cmd = "C:\\Winnt\\Notepad.exe";
var params = null;
if (inputParms == null)
{
params = document.Form1.filename.value;
}
oShell.ShellExecute(cmd, params, "", "open","1");
}
</SCRIPT>
<SCRIPT Language="JavaScript">
function runJSMode(ProgName)
{
var oShell = new ActiveXObject("WScript.Shell")
var TestRun = oShell.run(ProgName,1,0);
}
</SCRIPT>
<input type="file" name=filename>
<input type=button value="open" onclick="executeCommands()">
<input type=button value="open notepad" onclick="runJSMode('%WINDIR%\\Notepad.exe')">
</form>
<SCRIPT type="text/javascript" LANGUAGE="JavaScript">
function executeCommands(inputParms)
{
var oShell = new ActiveXObject("Shell.Application");
var cmd = "C:\\Winnt\\Notepad.exe";
var params = null;
if (inputParms == null)
{
params = document.Form1.filename.value;
}
oShell.ShellExecute(cmd, params, "", "open","1");
}
</SCRIPT>
<SCRIPT Language="JavaScript">
function runJSMode(ProgName)
{
var oShell = new ActiveXObject("WScript.Shell")
var TestRun = oShell.run(ProgName,1,0);
}
</SCRIPT>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询