views:

85

answers:

1

Never mind, I solved it.

It should just be

<a href="#" onclick="runnp()">Run notepad.exe</a>

Original question:

I'm trying to write a webpage that will launch programs on my local computer. How come only the vbscript version works? Nothing happens when I click the jscript link.

<html> 
<head> 
<script language="VBScript">
    Sub RunProgram 
        Set objShell = CreateObject("Wscript.Shell")
        objShell.Run "notepad.exe"
    End Sub
</script> 

<script language="jscript">
    function runnp() {
        File="notepad.exe";
        objShell = new ActiveXObject("WScript.Shell");
        objShell.run(File);
    }
</script> 

</head> 

<body> 
<a href="#" onclick="RunProgram">Run Program</a>
<A href="#" onClick="runnp(); return false;">Run notepad.exe</A>
</body> 
</html>

How can I make the jscript version work? (IE8 on XPsp2)

A: 

This appears to work:

<A href="#" onClick="runnp()">Run notepad.exe</A>

I don't know/understand why your sample does not!

bacar
I originally had <A href="#" onClick="runnp(); return false;">Run notepad.exe</A>. That didn't work. <a href="#" onclick="runnp()">Run notepad.exe</a> works.
Tobbe