在向HTA添加jQuery之后调用VBScript过程停止工作

时间:2015-11-20 10:03:55

标签: javascript jquery html vbscript hta

我正在尝试使用VBScript和jQuery构建HTA。

使用VBScript完成主脚本后,我来添加jQuery插件,但是现在遇到运行原始VBScript的问题。

我添加了

<meta http-equiv="X-UA-Compatible" content="IE=9"/>

到我的脚本顶部。

我只是试图从VBS调用一个子,按照下面的按钮:

<input type=button id=computerstart name=computerstart value='Retrieve Logs'
    width=100px onclick= "vbscript:GetLogs">

但是,当我点击“检索日志”按钮时,我收到如下错误消息:

  

错误:'GetLogs'未定义
  来源:Microsoft JScript运行时错误

这对我来说非常重要,因为它忽略了我的vbscript:GetLogs电话? 环顾四周我可以看到不同的文章说明哪种语言应该先行,虽然我已经尝试将JS重新定位在VBS之上,但似乎没有解决。

1 个答案:

答案 0 :(得分:1)

使用括号如下:

<input type=button id=computerstart name=computerstart value='Retrieve Logs'
    width=100px onclick= "vbscript:GetLogs()">

测试HTA

<html> 
  <head> 

    <meta http-equiv="x-ua-compatible" content="ie=9" />

    <title>33823891b.hta</title> 
    <HTA:APPLICATION ID = "33823891b" APPLICATIONNAME = "33823891b" >

    <script language="VBScript" type="text/vbscript">
        Sub ExitWindow()
            self.close()
        End Sub

        Sub GetLogs()
          Msgbox document.location & " works"
        End Sub
    </script>
  </head> 

  <body>
    <!-- original does not work with http-equiv="x-ua-compatible" content="ie=9" -->
    <input type=button id=computerstart name=computerstart value='Retrieve Logs'
           width=100px onclick= "vbscript:GetLogs">
    <br><br>
    <!-- adjusted, works with http-equiv="x-ua-compatible" content="ie=9" -->
    <input type=button id=computerstar2 name=computerstar2 value='Retrieve Log2'
           width=100px onclick='vbscript:GetLogs()'>
    <br><br>
    <!-- example, works in both cases -->
    <input id=runbutton type=button value="Exit" onClick="ExitWindow()">
  </body> 
</html>

另请参阅this my answer to another questionHTA使用不同的元http-equiv标记给出不同的结果,例如

<meta http-equiv="x-ua-compatible" content="IE=9">

<meta http-equiv="content-type" content="text/html">

(后者似乎与省略meta http-equiv标签相同。其他legacy document modes未经测试。