title: Can't access iframe content in IE
body: <p>I'm building a CMS application which I'm debugging now for IE. But things happen I cant comprehend.</p>
  
  <p>First I have a div with the content of a page. I extract the content of the div and with javascript I create an iFrame and append that to the div. This is for making the WYSIWYG-editor. Then when I want to add the content to the iFrame the problems start. IE can't access the iFrame's body for some reason. I can alert the iFrame's document, which gives me [object Document] or [object HTMLDocument], but when I then alert the body I get null.</p>
  
  <p>I use this function for getting the document as part of a javascript object:</p>
  
  <pre><code>iframedoc: function(aID) {
      if (document.getElementById(aID).contentDocument){
          return document.getElementById(aID).contentDocument;
      } else {
          var iFrame = document.getElementById(aID);
          return iFrame.contentWindow.document;
      }
  },
  </code></pre>
  
  <p>and this is where I call it for the first time:</p>
  
  <pre><code>tas[i].innerHTML = "";
  tas[i].appendChild(ta_edit_functions);
  tas[i].appendChild(ta_edit);
  tas[i].appendChild(ta_result);
  alert(ta.iframedoc(ta_edit_id));
  ta.iframedoc(ta_edit_id).body.innerHTML = ta_edit_content;
  ta.iframedoc(ta_edit_id).designMode = 'on';
  </code></pre>
  
  <p>Here I empty the div, append a div containing the WYSIWYG-functions, the iFrame and the textarea for eventually submitting the form.</p>
  
  <p>I'm testing in IE 8 and 9. Weirdest thing is that when I put an alert before first calling iframedoc in IE 8 I suddenly do get the body.</p>
  
  <p>I would be really grateful if someone could at least point me in the right direction. I really don't have a clue what's happening.</p>