【问题标题】:HTA output is not appearingHTA 输出未出现
【发布时间】:2014-02-20 15:12:02
【问题描述】:
<body bgcolor="white">

<!--Add your controls here-->

<table cellspacing=1 cellpadding=3 bgcolor="black">
 <tr>
  <td bgcolor="white">
<script type="text/vbscript">
    document.write(userName)
    window.Alert(userName)
</script>
  </td>
  <td bgcolor="white">row1_col2</td>
 </tr>
 <tr>
  <td bgcolor="white">row2_col1</td>
  <td bgcolor="white">row2_col2</td>
 </tr>
 <tr>
  <td bgcolor="white">row3_col1</td>
  <td bgcolor="white">row3_col2</td>
 </tr>
</table>
<!--{{InsertControlsHere}}-Do not remove this line-->
</body>
</html>

用户名仅出现在 HTML 上方的标签中。当我使用 window.Alert userName 时,该值会显示,但前提是该代码在上面的部分中。当我在正文中执行相同的 window.Alert 时,我得到“”(空字符串)。

我不知道发生了什么。我根据其中一个 cmets 的建议更新了代码。

【问题讨论】:

  • 我没有使用模板。我没有意识到 是专门用于 ASP 的。我有一些有限的 ASP 背景,并假设

标签: vbscript hta


【解决方案1】:

&lt;% %&gt; 是 ASP 语法,而不是 HTA 语法。不过,在 HTA 中,您可以使用嵌套的 &lt;script&gt; 标签:

<td><script type="text/vbscript">document.write userName</script></td>

顺便说一句,我强烈建议使用样式表来格式化标签(例如设置&lt;td&gt; 背景颜色)。它更干净,也更容易维护。

【讨论】:

  • 现在我更专注于在美化之前获取输出。你的解决方案也没有奏效。输出为空。
  • @softwareisfun 那么你没有全局变量userName(或者它没有值)。请使用定义/初始化变量的代码更新您的问题。
猜你喜欢
  • 2016-04-28
  • 1970-01-01
  • 2018-03-07
  • 2018-10-21
  • 1970-01-01
  • 1970-01-01
  • 2013-09-11
  • 1970-01-01
  • 2012-04-09
相关资源
最近更新 更多