title: Object tag added by innerHTML always null onload
body: <p>I am creating an object tag <code>onload</code>, and after creating it trying to access the object as follows:</p>
  
  <pre><code>function loadFile() {
  
  
  
          alert("loading file");
          gform.MOJWebTwain.HTTPPort = 9080;
          gform.MOJWebTwain.IfSSL = false;
          var result = gform.MOJWebTwain.HTTPDownload('myServer', existingDocumentPath);
          alert("result: "+result);
          var errorString = gform.MOJWebTwain.ErrorString;
          var errorCode = gform.MOJWebTwain.ErrorCode;
          if (!result) {
              alert("errorString: " + errorString);
              alert("errorCode " + errorCode);
          }
          document.body.style.opacity="100";
  
  }
  
  window.onload = function () {
      var DW_DWTContainerID = "gform:scan_area";
      var DW_FULLCLASSID = "123456-abcdef-12345-abcdef-123456"; // fixed
      var DW_PROCLASSID = "3d25aba1-abcdef-12345-abcdef-123456";  // the one in lpk file
  
      var DW_VersionCode = "6,3,1,0";
      var DW_InWindowsX86;
      var objString = "";
  
      var DW_ObjectName="MOJWebTwain"
      var DW_Width = 400;
      var DW_Height = 400;
      var DW_CABX86Path = "DynamSoft/DynamicWebTWAIN.cab";
      var DW_CABX64Path = "DynamSoft/DynamicWebTWAINx64.cab";
      var LPK_Path = "DynamSoft/DynamicWebTwain.lpk";
      ua = (navigator.userAgent.toLowerCase());
  
      objString += "&lt;object id='" + DW_ObjectName + "' "+"width='" + DW_Width +" ' "+"height='" + DW_Height+"' ";
  
      if (DW_InWindowsX86) objString += "codebase='" + DW_CABX86Path + "#version=" + DW_VersionCode + "' ";
      else objString += "codebase='" + DW_CABX64Path + "#version=" + DW_VersionCode + "' ";
  
      objString += " classid='clsid:" + DW_FULLCLASSID + "' viewastext&gt;";
  
      //alert("objString: "+objString);
  
      objString += " &lt;param name='_cx' value='847'/&gt;";
      objString += " &lt;param name='_cy' value='847'/&gt;";
      objString += " &lt;param name='JpgQuality' value='30'/&gt;";
      objString += " &lt;param name='Manufacturer' value='DynamSoft Corporation'/&gt;";
      objString += " &lt;param name='ProductFamily' value='Dynamic Web TWAIN'/&gt;";
      objString += " &lt;param name='ProductName' value='Dynamic Web TWAIN'/&gt;";
      objString += " &lt;param name='VersionInfo' value='Dynamic Web TWAIN 6,3,1,0'/&gt;";
      objString += " &lt;param name='TransferMode' value='0'/&gt;";
      objString += " &lt;param name='BorderStyle' value='0'/&gt;";
      objString += " &lt;param name='FTPUserName' value=''/&gt;";
      objString += " &lt;param name='FTPPassword' value=''/&gt;";
      objString += " &lt;param name='FTPPort' value='21'/&gt;";
      objString += " &lt;param name='HTTPUserName' value=''/&gt;";
      objString += " &lt;param name='HTTPPassword' value=''/&gt;";
      objString += " &lt;param name='HTTPPort' value='9080' /&gt;";
      objString += " &lt;param name='ProxyServer' value=''/&gt;";
      objString += " &lt;param name='IfDisableSourceAfterAcquire' value='0'/&gt;";
      objString += " &lt;param name='IfShowUI' value='0'/&gt;";
      objString += " &lt;param name='IfModalUI' value='-1'/&gt;";
      objString += " &lt;param name='IfTiffMultiPage' value='-1'/&gt;";
      objString += " &lt;param name='IfThrowException' value='0'/&gt;";
      objString += " &lt;param name='MaxImagesInBuffer' value='99'/&gt;";
      objString += " &lt;param name='TIFFCompressionType' value='0'/&gt;";
      objString += " &lt;param name='IfFitWindow' value='-1' /&gt;";
      objString += " &lt;param name='IfSSL' value='0' /&gt;";
      objString += " &lt;/object&gt;";
  
      var obj2String = "&lt;object "
          +"classid='clsid:"+DW_PROCLASSID+"'"+"&gt;"
          +"&lt;param name='LPKPath' value='"+LPK_Path+"'"+"/&gt;";
          +"&lt;/object&gt;";
  
      //alert("obj2String "+obj2String);
  
      var obj2String = "&lt;object classid='clsid:"+DW_PROCLASSID+"'&gt;"
          +"&lt;param name='LPKPath' value='"+LPK_Path+"'"+"/&gt;";
          +"&lt;/object&gt;";
  
      var objects_string=obj2String +" "+objString;
  
      DWTContainer = document.getElementById(DW_DWTContainerID);                          
      DWTContainer.innerHTML = objects_string;
  
      loadFile();
  }
  </code></pre>
  
  <p><strong>HTML</strong> is as follows:</p>
  
  <pre><code>&lt;form id="gform"&gt;
    &lt;div id=gform:scan_area""&gt;
  
     &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>But I always get that the object I created is <code>null</code> in this line:</p>
  
  <pre><code>gform.MOJWebTwain.HTTPPort = 9080;
  </code></pre>
  
  <p>If the object was added statically in the page (i.e. not through <code>onload</code>), I don't get this exception.</p>