Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VBScript object required

Tags:

vbscript

hta

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

Just can't find the problem why this is giving me the error:

Object required "ProxyStatus"

(and yes I have a span element with the id of proxyStatus)

like image 821
Steve Avatar asked Jun 02 '26 11:06

Steve


1 Answers

Go back to this code

Set ProxyStatus = document.getElementById("proxyStatus")
Set ToggleProxyButton = document.getElementById("toggleProxy")
Set ProxyServerInput = document.getElementById("proxyServer")

The only mistake here as long as the HTML is correctly formed is the use of Set when you are just referencing existing objects in the DOM. Try removing the Set from these lines like this;

ProxyStatus = document.getElementById("proxyStatus")
ToggleProxyButton = document.getElementById("toggleProxy")
ProxyServerInput = document.getElementById("proxyServer")
like image 157
user692942 Avatar answered Jun 04 '26 12:06

user692942