I have some code on a classic ASP page that is attempting to get the innerHTML of a <div> element.
Dim oElm
Set oElm = document.getElementById("screenDiv")
if oElm Is Nothing then
'''
else
document.getElementById("screenDiv").innerHTML = ""
end if
I’ve tried the above but I’m getting the Object Required error.
What do I need to do to get around this error?
This means the code is located before the element, so when it executes, such
element does not exist.
To solve this, have the code execute in the
onloadevent:Credit for the correct way goes to Korikulum, and the official documentation can be found here.
Live test case. (IE only)