title: Using postmessage to communicate with iframe - where is the error?
body: <p>I have a Greasemonkey script that should send a postmessage to an embedded iframe where the same script starts a function. My attention is sending an easy message to trigger a function inside the iframe. The website and the iframe are not on the same domain. My js skills are quite bad and I can't find the issue.</p>
  
  <p>Thx for reading</p>
  
  <pre><code>// ==UserScript==
  // @name        Test
  // @namespace   
  // @include     domainA
  // @include     domainB
  // @version     1
  // @grant       none
  // ==/UserScript==
  
  if ("domainA" === location.hostname)
  {
    if (window === top) // prevents the script from running twice on domain A
    {
      window.setTimeout(delay, 15000);
      function delay()
      {
        console.log("Delay");
        document.getElementsByTagName("Iframe")[0].contentWindow.postMessage('message', 'domainB');  //The issue is probably here
      }
    }  
  }
  else // domain B 
  { 
   window.onmessage = function()  // or here
   {  
    console.log("Done"); // Didnt start
   }
  }
  </code></pre>
  
  <p>edit: Iam using Firefox</p>