title: `Uncaught TypeError: Cannot read property 'postMessage' of undefined ` error while sending cross domain messages using EasyXDM
body: <p>I am trying to make a data exchange system between two websites at their client sides. I am using EasyXDM for this. (<a href="http://easyxdm.net/" rel="noreferrer">http://easyxdm.net/</a>). Here is my code of parent website:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head runat="server"&gt;
      &lt;title&gt;EasyXDM Test&lt;/title&gt;
      &lt;script type="text/javascript" src="easyXDM.debug.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
          var serv_socket = new easyXDM.Socket({
              remote: "http://localhost:39452/EasyXDM/Default.aspx",
              onMessage: function (message, origin) {
                  document.getElementById('msg').innerText="Received '" + message + "' from '" + origin + "'";
              },
              onReady: function () {
                  serv_socket.postMessage("ID");
              }
          });
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form id="form1"&gt;
      &lt;div&gt;
      &lt;iframe src="http://localhost:39452/EasyXDM/Default.aspx"&gt;&lt;/iframe&gt;
          &lt;input type="text" id="msgtext" /&gt;&lt;a href="#" onclick="serv_socket.postMessage('d')"&gt;Send message&lt;/a&gt;
          &lt;div id="msg"&gt;&lt;/div&gt;
      &lt;/div&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And below is the child website's code that is located at <code>localhost:39452</code> domain:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head runat="server"&gt;
      &lt;title&gt;Server&lt;/title&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form id="form1"&gt;
          &lt;input type="text" id="msgtext" /&gt;
          &lt;div&gt;
              &lt;script type="text/javascript" src="easyXDM.debug.js"&gt;&lt;/script&gt;
              &lt;script type="text/javascript"&gt;
                  var socket = new easyXDM.Socket({
                      onMessage: function (message, origin) {
                          //document.getElementById('msg').innerText="Received '" + message + "' from '" + origin + "'";
                          socket.postMessage(message);
                      },
                      onReady: function (msg) {
                          socket.postMessage(msg);
                      }
                  });
                  function send() {
                      socket.postMessage('this is message from server');
                  }
              &lt;/script&gt;
              &lt;a href="#" id="sender" onclick="send()"&gt;Send message&lt;/a&gt;
          &lt;/div&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The problem is that, when I click <code>Send message</code> on child website and call <code>socket.postMessage()</code> it says <code>Uncaught TypeError: Cannot read property 'postMessage' of undefined.</code>. Please tell me how to solve this issue?</p>
  
  <p><strong>Update:</strong> <code>socket</code> is becoming null or undefined somehow.</p>