title: iframe cross domain messaging with jQuery postMessage plugin
body: <p>I am trying to communicate between a child iframe and its parent using the following plugin:</p>
  
  <p><a href="http://benalman.com/projects/jquery-postmessage-plugin/" rel="noreferrer">http://benalman.com/projects/jquery-postmessage-plugin/</a></p>
  
  <p>I can follow the example and post a message from the child to the parent but not the other way and i really need to be able to communicate both ways.</p>
  
  <p>The code on the parent is as follows:</p>
  
  <pre><code>var origin = document.location.protocol + '//' + document.location.host,
      src = origin + '/Custom/Ui/Baseline/html/iframe-data-cash.htm#' + encodeURIComponent(document.location.href);
  
  $(function () {
  
      var $holder = $('#iframe'),
          height,
          $iframe = $('&lt;iframe src="' + src + '" id="data-cash-iframe" width="100%" scrolling="no" allowtransparency="true" seamless="seamless" frameborder="0" marginheight="0" marginwidth="0"&gt;&lt;/iframe&gt;');
  
      // append iframe to DOM
      $holder.append($iframe);
  
  });
  
  $(window).load(function () {
      $.postMessage(
          'hello world',
          src,
          parent.document.getElementById('data-cash-iframe').contentWindow
      );
  });
  </code></pre>
  
  <p>And the code on the child is as follows:</p>
  
  <pre><code>$(function () {
  
      var parentURL = decodeURIComponent(document.location.hash.replace(/^#/, ''));
  
      $.receiveMessage(
          function (e) {
              alert(e.data);
          },
          parentURL
      );
  
  });
  </code></pre>
  
  <p>I really cannot see why this is not working and am in desperate need of help!</p>