Option Explicit
Dim output, ProxyEnable, ProxyServer, wshShell, doc
Sub Window_onLoad
loadProxySettings()
End Sub
Set wshShell = CreateObject("WScript.Shell")
ProxyEnable = wshShell.RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable")
ProxyServer = wshShell.RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyServer")
Function loadProxySettings()
If ProxyEnable = 1 Then
proxyStatus.className = "enabled"
proxyStatus.innerHTML = "Proxy aktiv"
toggleProxyButton.value = "Proxy deaktivieren"
proxyServer.value = ProxyServer
Else
proxyStatus.className = "disabled"
proxyStatus.innerHTML = "Proxy deaktiviert"
toggleProxyButton.value = "Proxy aktivieren"
proxyServer.value = ProxyServer
End If
End Function
无法找到问题,为什么这会给我错误:
对象需要“ProxyStatus”
(是的,我有span
id
proxyStatus
的{{1}}元素
答案 0 :(得分:1)
Set ProxyStatus = document.getElementById("proxyStatus")
Set ToggleProxyButton = document.getElementById("toggleProxy")
Set ProxyServerInput = document.getElementById("proxyServer")
只要正确形成HTML,这里唯一的错误就是在您只是引用DOM中的现有对象时使用Set
。尝试从这些行中删除Set
;
ProxyStatus = document.getElementById("proxyStatus")
ToggleProxyButton = document.getElementById("toggleProxy")
ProxyServerInput = document.getElementById("proxyServer")
答案 1 :(得分:0)
在HTA中,你可以使用ID和变量等元素的ID,即如果你有这样的元素:
<p>foo <span id="proxyStatus">something</span> bar</p>
你应该能够在你的代码中使用它,而不必先做任何事情:
MsgBox proxyStatus.innerText