...

View Full Version : How can launch a clientside application in javascript



Frances Ford
01-20-2003, 04:50 PM
I have a web based application that displays an htm page to the client. Is it possible to have say a button for the user to press to run a local application and keep the htm open?

Also is it possible to display the printers that are available to that user by pressing a button and inserting on the current htm?

Thanks for help.

Borgtex
01-20-2003, 07:34 PM
no with javascript; maybe with ActiveX...

Graeme Hackston
01-20-2003, 09:49 PM
This doesn't fit your situation but you might find it of use.

As Borgtex suggested this is activeX (IE only). Notice that the paths are DOS paths. You can get those in Windows by looking at the properties of the file.

For local use, you won't get the activeX warning if you save the page as an .hta file (real simple) rather than .html



<html>
<head>
<title></title>
<script type="text/javascript">

fso = new ActiveXObject("Scripting.FileSystemObject");

function RunProgram(Program_Path) {
Default_Value = Program_Path.match(new RegExp("Default", "i"))
if (Default_Value) {
} else {
new ActiveXObject("WScript.Shell").Run(Program_Path,3,false)
}
}

</script>
</head>
<body>

<select onchange="RunProgram(this.value)">
<option value="Default" selected>Launch Program</option>
<option value="C:\\PROGRA~1\\MICROS~1\\MICROS~4.LNK">Word</option>
<option value="C:\\WINDOWS\\EXPLORER.EXE">Explorer</option>
<option value="C:\\PROGRA~1\\MOZILLA.ORG\\MOZILLA\\MOZILLA.EXE">Mozilla 1.0</option>
</select>

</body>
</html>

Frances Ford
01-21-2003, 10:32 AM
I don't know anything about WScript, but when I run the htm I get the message:
'The system cannot find the file specified'.
Any help appreciated.

Graeme Hackston
01-21-2003, 10:48 PM
If your using windows browse to, right click and select "properties" on each folder in the path to your .exe

In the window that pops up you'll see the following

MS-DOS name: some~DOSname .

Enter the DOS name of each folder in the path and finally the exec file between the double back slashes in the <option> value

<edit>

more info on this here

http://www.codingforums.com/showthread.php?s=&threadid=16467

</edit>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum