简体   繁体   中英

How to Run an Application from HTML?

I am trying to open a file from Firefox or Chrome browser. I have written the following code and it is successfully opening Notepad from Internet Explorer. Kindly tell me how to write this code if i want to open an Application from Firefox or Chrome Browser.

<html>
<head>
    <title>Application Executer</title>
    <HTA:APPLICATION ID="oMyApp" 
        APPLICATIONNAME="Application Executer" 
        BORDER="no"
        CAPTION="no"
        SHOWINTASKBAR="yes"
        SINGLEINSTANCE="yes"
        SYSMENU="yes"
        SCROLL="no"
        WINDOWSTATE="normal">
    <script type="text/javascript" language="javascript">
        function RunFile() {

        //WshShell= new XMLHttpRequest("WScript.Shell");
        //WshShell.Run("c:/windows/system32/notepad.exe", 1, false);

        WshShell = new ActiveXObject("WScript.Shell");  
        WshShell.Run("c:/windows/system32/notepad.exe", 1, false);
        }
    </script>
</head>
<body>
    <input type="button" value="Run Notepad" onclick="RunFile();"/>
</body>
</html>

由于安全问题,这是不可能的。它仅适用于记事本和受信任的程序。如今,谷歌浏览器仅允许将谷歌的插件安装在Chrome上。因此用户应先下载文件然后运行它。可以轻松破解或格式化用户磁盘。

对于上面完整的回答(reza jafari answer),我应该说,您是否曾见过任何在您的计算机上打开过.exe文件的网站?绝对没有。因此,由于安全原因,这是不可能的

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM