从html按钮调用vbscript函数 [英] Calling vbscript function from html button

查看:226
本文介绍了从html按钮调用vbscript函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我做的事情完全错误或解决方案显而易见,请不要感到惊讶.

Don't be surprised if what I'm doing is completely wrong or if the solution is obvious.

<script type="text/vbscript">
    Function AddPrinter()
        Set objNetwork = CreateObject("WScript.Network")
        objNetwork.AddWindowsPrinterConnection "\\a2031slhsfile1\2031CAT-T113-HP4014dn"
        objNetwork.SetDefaultPrinter "\\a2031slhsfile1\2031CAT-T113-HP4014dn"
        MsgBox "The printer was added and set as the default printer."
    End Function
</script>

我将上述vbscript添加到了头部的HTML文档中,其中一个按钮具有以下属性:

I added the above vbscript to an HTML document in the head section and one of the buttons has the following property:

onclick="AddPrinter()"

在Google上搜索一个小时后,我发现的内容不多.我发现的东西没有用.它怎么知道您是从javascript还是从vbscript调用函数,还是无论如何?

I didn't find much about this when searching on Google for an hour. What I did find didn't work. How does it know whether you're calling the function from javascript or vbscript or whatever anyway?

我收到此错误:

SCRIPT429: ActiveX component can't create object: 'WScript.Network'

推荐答案

您的Internet Explorer安全设置会阻止创建ActiveX控件.您需要允许初始化和脚本化未标记为安全的ActiveX控件脚本".

Your Internet Explorer security settings prevent the creation of the ActiveX control. You need to allow "initialize and script ActiveX controls not marked as safe for scripting".

这篇关于从html按钮调用vbscript函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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