什么是一些方法来链接并运行本地.exe文件在本地浏览器 [英] What are some methods to link to and run a local .exe file in a local browser

查看:186
本文介绍了什么是一些方法来链接并运行本地.exe文件在本地浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用的HTML / JavaScript来在本地浏览器运行本地.exe文件。 .exe文件将生成ASCI文本和我有程序性封装在HTML清晰浏览器的文本。但我想把它加载从.exe新的输出在当前浏览器,取代现在有什么

I am trying to use html/javascript to run a local .exe file in a local browser. The .exe file will generate asci text and I have it programed to encapsulate the text in html legible to the browser. But I want to have it load the new output from the .exe in the current browser, replacing whats there now.

推荐答案

有两种解决办法,我能想到的。

There are two solutions I can think of.

在IE浏览器 - 在这里,是打开记事本的样本。
你在那里把你的可执行文件,然后把它写它的文件,然后读取该文件。

In IE - Here is a sample to open notepad. You place your executable there and then have it write it's file and then read the file.

 <script>
 function go() {
   w = new ActiveXObject("WScript.Shell");
   w.run('notepad.exe');
   return true;
   }

 </script>

 <form>
   Run Notepad (Window with explorer only)
     <input type="button" value="Go" 
     onClick="return go()">
</FORM>

下面是一个示例从文件读取

Here is a sample for reading from a file

// define constants
// Note: if a file exists, using forWriting will set
// the contents of the file to zero before writing to
// it. 
var forReading = 1, forWriting = 2, forAppending = 8;
// define array to store lines. 
rline = new Array();
// Create the object 
fs = new ActiveXObject("Scripting.FileSystemObject");
f = fs.GetFile("test.txt");
// Open the file 
is = f.OpenAsTextStream( forReading, 0 );
// start and continue to read until we hit
// the end of the file. 
var count = 0;
while( !is.AtEndOfStream ){
   rline[count] = is.ReadLine();
   count++;
}
// Close the stream 
is.Close();
// Place the contents of the array into 
// a variable. 
var msg = "";
for(i = 0; i < rline.length; i++){
   msg += rline[i] + "\n";
}
// Give the users something to talk about. 

WScript.Echo( msg );

2)创建一个签名Java Applet和通过JavaScript对它说话

也许有就是从JavaScript跟一个Java小程序,然后让小程序做的工作的方式 - 它很可能需要签署

2) Create a signed Java Applet and talk to it through JavaScript

Maybe there is a way to talk to a Java Applet from the Javascript and then have the Applet do the work - It would probably need to be signed.

这篇关于什么是一些方法来链接并运行本地.exe文件在本地浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆