Adam Sargant
Adam Sargant

Reputation: 441

Object doesn't support this property or method: 'Document.getElementById' in IE10

I'm having to debug some vbscript in IE10. The script launches the microsoft Remote Desktop ActiveX control and has worked absolutely fine up to and including IE9. In IE10 (non-compatibility mode) it throws an error "Object doesn't support this property or method: 'Document.getElementById'"

The relevant section of code is

sub OnControlLoad
   set Control = Document.getElementById("MsRdpClient")
   if Not Control is Nothing then
      if Control.readyState = 4 then
         Document.all.connectButton.disabled = FALSE
      end if
   end if
end sub

and the object with id MsRdpClient is

<OBJECT language="vbscript" ID="MsRdpClient"
onreadystatechange="OnControlLoad"
CLASSID="CLSID:9059f30f-4eb1-4bd2-9fdc-36f43a218f4a"
CODEBASE="msrdp.cab#version=5,1,2600,1095"
WIDTH=800
HEIGHT=600>
</OBJECT>

I have tested with some very simple scripts such as

<script language="VbScript">
Function btnCheck_OnClick()
    MsgBox ("test")
    MsgBox (Document.getElementById("txtName").Value) 
End Function

</script>

<form name="form1" method="post" action="">
<input type="text" name="txtName" id="txtName" value="TEST">
<input type="button" name="btnCheck" value="GetValue">
</form>

and this throws the same error in IE10 non-compatibility mode (Object doesn't support this property or method: 'Document.getElementById'), but works fine in IE10 compatibility mode and IE9. Does anyone have any idea why the document object in vbscript does not have the getElementByID method available, and more importantly, how to get round it?

Upvotes: 0

Views: 5570

Answers (1)

Fenixp
Fenixp

Reputation: 645

It's document, not Document. I suspect the behaviour of older versions of IE worked incorrectly.

MDN

Upvotes: 2

Related Questions