jscript+wsh 无法启动 notepad.exe,vbscript+wsh 可以。为什么?

发布于 2024-09-14 19:39:41 字数 902 浏览 3 评论 0原文

没关系,我解决了它。

它应该只是

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

原始问题:

我正在尝试编写一个在本地计算机上启动程序的网页。为什么只有 vbscript 版本有效?当我单击 jscript 链接时没有任何反应。

<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>

如何使 jscript 版本正常工作? (XPsp2 上的 IE8)

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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

千紇 2024-09-21 19:39:41

这似乎有效:

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

我不知道/理解为什么你的样本不起作用!

This appears to work:

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文