title: cross-domain iframe contentWindow
body: <p>I would like to exchange messages via postMessage with an iframe on my page that is pointing to a page on a different domain (which I own). </p>
  
  <p>Just by looking at the demo <a href="http://html5demos.com/postmessage2" rel="nofollow">http://html5demos.com/postmessage2</a> and reading a bit on the web, I understood that I have to call postMessage on the contentWindow of the iframe. i.e.</p>
  
  <pre><code>var iframe=document.getElementById('myframe');
  var win=iframe.contentWindow;
  
  //just send the message
  win.postMessage('Help!',mydomain);
  </code></pre>
  
  <p>Now, the point is that, when I try to get the contentWindow, I get "DOM Exception" so I cannot send any message to the iframe. </p>
  
  <p>I am wondering if I need to set up something on the page that is displayed within the iframe to accept this cross-domain communication... but I have to say that I am completely clueless...</p>
  
  <p>Any help would be appreciated.</p>