title: Passing Messages from iFrame Across all Browsers
body: <p>I have an embed-able iframe that will be used on 3rd party sites. It has several forms to fill out, and at the end must inform the parent page that it is done.</p>
  
  <p>In other words, <strong>the iframe needs to pass a message to it's parent when a button is clicked.</strong></p>
  
  <p>After wading through oceans of "No, cross-domain policy is a jerk" stuff, I found <a href="https://developer.mozilla.org/en/DOM/window.postMessage">window.postMessage</a>, part of the HTML5 Draft Specification.</p>
  
  <p>Basically, you place the following JavaScript in your page to capture a message from the iframe:</p>
  
  <pre><code>window.addEventListener('message', goToThing, false);
  
  function goToThing(event) {
      //check the origin, to make sure it comes from a trusted source.
      if(event.origin !== 'http://localhost')
          return;
  
      //the event.data should be the id, a number.
      //if it is, got to the page, using the id.
      if(!isNaN(event.data))
          window.location.href = 'http://localhost/somepage/' + event.data;
  }
  </code></pre>
  
  <p>Then in the iframe, have some JavaScript that sends a message to the parent:</p>
  
  <pre><code>$('form').submit(function(){
      parent.postMessage(someId, '*');
  });
  </code></pre>
  
  <p>Awesome, right? Only problem is it doesn't seem to work in any version of IE. So, my question is this: Given that I need to pass a message <em>from</em> an iframe to it's parent (both of which I control), <strong>is there a method I can use that will work across any (>IE6) browser?</strong></p>