HTA:VBScript 字符串内的 Javascript 函数会导致 HTA 出现错误?
我在 HTA 中使用 javascript/vbscript,并在 VBS 循环内为我的 HTA 接口构建表。当我简单地运行:
strHTML = strHTML & "<tr>" &_
"<td><a id=""" & aName & """ href=""javascript:toggleRow('" & rowName & "','" & arrTemp(1) & "','" & aName & "')"">+ </a>" & arrTemp(1) & "</td>" & _
"<td>" & arrTemp(2) & "</td><td class='status'>" & _
"<img onclick=""displayRow()"" src='" & strStatus & "' border='0'></td></tr>" & _
"<tr id='" & rowName & "' style=""display:none;""><td id='" & arrTemp(1) & "' colspan=""3"">test</td></tr>"
...我的 HTA 显示正常。但是,当我尝试将 Javascript 函数添加到我的 TR 标记时,我收到各种 VBS 错误:
strHTML = strHTML & "<tr onmouseover=""ChangeColor(this, true);"" onmouseout=""ChangeColor(this, false);"" onclick=""DoNav();"">" &_
"<td><a id=""" & aName & """ href=""javascript:toggleRow('" & rowName & "','" & arrTemp(1) & "','" & aName & "')"">+ </a>" & arrTemp(1) & "</td>" & _
"<td>" & arrTemp(2) & "</td><td class='status'>" & _
"<img onclick=""displayRow()"" src='" & strStatus & "' border='0'></td></tr>" & _
"<tr id='" & rowName & "' style=""display:none;""><td id='" & arrTemp(1) & "' colspan=""3"">test</td></tr>"
我很确定我已经正确注释掉了额外的引号,但我无法让它工作。谁能在第一行看到我做错了什么吗?
编辑:此外,如果我保留所有 on* 事件及其关联的 4 个引号,但删除所有内部 javascript 函数,则页面加载正常(如果这有帮助的话)
I'm using both javascript/vbscript in my HTA and am building the table for my HTA interface inside of a VBS loop. When I simply run:
strHTML = strHTML & "<tr>" &_
"<td><a id=""" & aName & """ href=""javascript:toggleRow('" & rowName & "','" & arrTemp(1) & "','" & aName & "')"">+ </a>" & arrTemp(1) & "</td>" & _
"<td>" & arrTemp(2) & "</td><td class='status'>" & _
"<img onclick=""displayRow()"" src='" & strStatus & "' border='0'></td></tr>" & _
"<tr id='" & rowName & "' style=""display:none;""><td id='" & arrTemp(1) & "' colspan=""3"">test</td></tr>"
...my HTA displays fine. But when I try to add Javascript functions to my TR tag, I get all sorts of VBS errors:
strHTML = strHTML & "<tr onmouseover=""ChangeColor(this, true);"" onmouseout=""ChangeColor(this, false);"" onclick=""DoNav();"">" &_
"<td><a id=""" & aName & """ href=""javascript:toggleRow('" & rowName & "','" & arrTemp(1) & "','" & aName & "')"">+ </a>" & arrTemp(1) & "</td>" & _
"<td>" & arrTemp(2) & "</td><td class='status'>" & _
"<img onclick=""displayRow()"" src='" & strStatus & "' border='0'></td></tr>" & _
"<tr id='" & rowName & "' style=""display:none;""><td id='" & arrTemp(1) & "' colspan=""3"">test</td></tr>"
I'm pretty sure I've commented out the extra quotations correctly but I can't get it to work. Can anyone see what I'm doing wrong just on the first line?
Edit: Additionally, if i leave all of the on* events with their associated 4 quotes but remove all of the internal javascript functions, the page loads fine if that helps at all
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
啊……找到答案了。 HTA 将这些函数解释为 VBS 函数。对 javascript 的显式声明就是这样的:
Ah... found the answer. the HTA was interpreting the functions as VBS functions. An explicit declaration to javascript is what did the trick: