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

时间:2016-05-16 22:44:41

标签: html vbscript hta

这一定很容易,但是我把头发拉了出来。

我正在编写一个新的HTA,之前写过几个 - 但是我无法使InnerHTML属性工作。

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

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

我将text1.innerHTML代码区域与其他HTA代码区域进行了比较,这些代码区域工作正常并且看不出任何差异。我还检查了标题/元信息,那里没什么不同。

以下是代码剪辑:

<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>

1 个答案:

答案 0 :(得分:3)

您没有在以下位置关闭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