Object 不支持此 属性 或方法 - InnerHTML VBS HTA 问题

Object does not support this property or method - InnerHTML VBS HTA Issue

这一定很简单,但我正在努力。

我正在写一个新的 HTA,以前写过几个 - 但我无法让 InnerHTML 属性 工作。

我收到的错误在第 10 行。错误是:

Object doesn't support this property or method: 'text1.innerHTML'

我已经将我的 text1.innerHTML 代码区域与其他 HTA 中的代码区域进行了比较,它们工作正常并且看不出有任何区别。我还检查了 header / 元信息,那里没有什么不同。

以下是代码片段:

<script language="VBScript">

Sub Window_OnLoad() 

Self.resizeTo 800,670

Set objShell = CreateObject("WScript.Shell")
strShort = objShell.ExpandEnvironmentStrings("%USERDOMAIN%")
If strShort = "DOMAINA" Then text1.innerHTML="VPN Type 1"
If strShort = "DomainB" Then text1.innerHTML="VPN Type 2"
  'This method will be called when the application loads
  'Add your code here
End Sub

Sub EnableUpgrade()
If UACheckbox.Checked = True Then
    UpgradeButton.Disabled = False
Else
    UpgradeButton.Disabled = True
End If
End Sub

Sub OnClickButtonUpgradeButton()
  'This method will be called when button "UpgradeButton" is clicked
  'Add your code here
End Sub
</script>


<html>
<head>
<title>Test HTA</title></title>
<link href="Main.css" rel="stylesheet" type="text/css" />
<HTA:APPLICATION
  APPLICATIONNAME="Babcock GlobalProtect Deployment"
  ID="GlobalProtectDeployment"
  VERSION="1.0"
  MAXIMIZEBUTTON="no"
  MINIMIZEBUTTON="no"
  SCROLL="auto"/>
</head>


<body bgcolor="white">
<div class="wrappr">
    <table class="top">
        <tr class="top">
            <td colspan="2">
                <div class="wrapper">
                <div class="topone" align=left><img style="width:125px;border:0;" vertical-align"center" src="WebVersion.png"></div>&nbsp;&nbsp&nbsp;&nbsp
                <div class="topthree"><h1>Test HTA</h1>
            </td>
        </tr>
    </table>
    <table>
        <tr><td>
        <br>This upgrade will replace the <span ID = "Text1"> VPN software on this computer. This is mandatory, as <span ID = "text1"> will soon be decomissioned. The new VPN software that will be installed is VPNC.
        </td></tr>
        <br>    
        <input onclick="EnableUpgrade "type="checkbox" name="UACheckbox" id="UACheckbox">&nbspI confirm I have completed the above requirements
        <br>
        <input type="button" name="UpgradeButton" id="UpgradeButton" value="Upgrade" onclick="OnClickButtonUpgradeButton" disabled>
    </table>
</div>
<!--Add your controls here-->


<!--{{InsertControlsHere}}-Do not remove this line-->
</body>
</html>

您没有关闭 span 标签:

<br>This upgrade will replace the <span ID = "Text1"> VPN software on this computer. This is mandatory, as <span ID = "text1"> will soon be decomissioned. The new VPN software that will be installed is VPNC.

并且 id 个元素在页面中应该是唯一的。

我想你需要的是:

<br>This upgrade will replace the <span ID = "Text1"></span> VPN software on this computer. This is mandatory, as <span ID = "Text2"></span> will soon be decommissioned. The new VPN software that will be installed is VPNC.

并且在onLoad函数中,

If strShort = "DOMAINA" Then 
    Text1.innerHTML="VPN Type 1"
    Text2.innerHTML="VPN Type 1"
End if