title: How can I get contentWindow for an Object element in IE7
body: <p>I have a HTML object element like this:<br>
  <code>&lt;object title="Search results as XML" standby="Loading XML document..." type="text/xml"
  data="/__CA25761100195585.nsf/WebPrintListingXML?OpenAgent&amp;date1=01/06/2009"
  width="100%" height="100%" border="0" name="resultIFrame" id="resultIFrame">
  Error: could not embed search results.
  &lt;/object></code></p>
  
  <p>I also have this javascript function (alert() calls added for debugging):  </p>
  
  <pre><code>function getFrameByName(fParent,fName)
  {
      var fArray=fParent.frames;
      if (!fName) return;
      if (fArray) {
          if (fArray.length) {
              for (var i=0; i&lt;fArray.length; i++) {
                  alert('loop '+i);
                  if (fArray[i]) {
                      if (fArray[i].name==fName) return fArray[i];
                  }
              }
          }
      }
      var tmp=document.getElementsByName(fName);
      if (tmp[0]) {
          alert('returning '+tmp[0]);
          if (!(tmp[0].contentWindow)) alert('contentWindow is null');
          return tmp[0].contentWindow;
      }
  }</code></pre>
  
  <p>And finally, this button is meant to print the content of the Object element:<br>
  <code>&lt;input type="button" value="Print" name="printBtn"
      onclick="getFrameByName(window,'resultIFrame').print();"></code></p>
  
  <p>The button works perfectly in Firefox.
  Opera is good enough, though it prints the main document instead of just the object.
  IE7 gives the following error details:<br>
      Line: 57
      Char: 1
      Error: 'undefined' is null or not an object</p>
  
  <p>Line 57 is where the button's "input" tag starts in the HTML source.
  Thanks to the <code>alert('contentWindow is null')</code> call in the JS function, I know that the object I'm getting in IE has no contentWindow property.  </p>
  
  <p>I have tried changing the <code>object</code> tag to an <code>iframe</code> tag. This changes the JS behaviour, but causes other issues such as the <code>height</code> attribute being ignored and the content not displaying.<br>
  Sticking with an <code>object</code> tag, how can I get this Object's window in IE7?</p>