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 htm
Would it make it easier if, rather than running the browser and application separately, maybe you had an application you run which contains a webbrowser - then talking between them is easier because you can get access to the inner workings of the browser ... Just a thought.
There are two solutions I can think of.
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 );
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.
The short answer: you can't do it without writing a browser plug-in of some sort. Probably there's a simpler way of doing what you want.