javascript 如何使用javascript启动应用程序?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6912372/
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
How to launch an application using javascript?
提问by Sangam254
I want to launch an application eg. notepad or MSword on click of a button using javascript function. I have tried ActiveXObject meant for IE.
我想启动一个应用程序,例如。记事本或 MSword 使用 javascript 函数单击按钮。我尝试过用于 IE 的 ActiveXObject。
function runApp()
{
var shell = new ActiveXObject("WScript.shell");
shell.run("notepad.exe", 1, True);
}
I need a solution which supports Firefox.Please suggest.
Thanks in advance.
我需要一个支持Firefox的解决方案。请建议。
提前致谢。
回答by lamelas
You cannot use ActiveX commands from Firefox. See more here: http://support.mozilla.com/en-US/kb/activexAnd you cannot launch an application using Javascript. Maybe with a Java Applet, or something.
您不能使用来自 Firefox 的 ActiveX 命令。在此处查看更多信息:http: //support.mozilla.com/en-US/kb/activex而且您无法使用 Javascript 启动应用程序。也许使用 Java Applet 或其他东西。
回答by BonyT
You can't - browser security prohibits it from linking with the file-system or other applications on a users machine.
你不能 - 浏览器安全禁止它与用户机器上的文件系统或其他应用程序链接。
回答by James Gaunt
The best thing I can think off is serving a file which would be linked to open in the application concerned. So if you serve a .doc file the user would generally open it in Word.. assuming Word is installed and configured that way.. there is no way to guarantee this.
我能想到的最好的事情是提供一个文件,该文件将链接到在相关应用程序中打开。因此,如果您提供 .doc 文件,用户通常会在 Word 中打开它.. 假设 Word 以这种方式安装和配置.. 没有办法保证这一点。
But you can't then interact with the application directly from the browser - as others have pointed out this would be a malware nightmare if possible.
但是你不能直接从浏览器与应用程序交互 - 正如其他人指出的那样,如果可能的话,这将是恶意软件的噩梦。