title: Simple cross-domain iframe postMessage works in jsfiddle but not locally
body: <p>I'm trying to work with an <code>iframe</code> on another domain, and I got stuck at the "Hello World!" stage.</p>
  
  <p>I have two files, served over two static servers. I refer to those files over two different domains and different ports.</p>
  
  <h3><code>http://localhost:8080/index.html</code></h3>
  
  <pre><code>&lt;iframe id="target" src="http://hocallost:8081/iframe.html" frameborder="1"&gt;&lt;/iframe&gt;
  
  &lt;script&gt;
      var target = document.getElementById('target');
      target.contentWindow.postMessage('hello', '*');
  &lt;/script&gt;
  </code></pre>
  
  <h3><code>http://hocallost:8081/iframe.html</code></h3>
  
  <pre><code>&lt;script&gt;
      window.addEventListener('message', function receiveMessage(message) {
          console.log(message);
          document.body.textContent = "Hello World!";
      }, false);
  &lt;/script&gt;
  </code></pre>
  
  <p>Now, locally, the message event handler isn't even firing. I have no message, console.log is not invoked and my breakpoint isn't breaking.</p>
  
  <p>When I took <code>index.html</code>'s source and pasted it into <a href="http://jsfiddle.net" rel="nofollow">JSFiddle</a>, it works! The event fires and I get the Hello World.</p>
  
  <p>Now, I obviously won't be able to rely on JSFiddle on my production application, what am I doing wrong? What am I missing here? Does JSFiddle do something behind the scenes that I'm failing to do? </p>