title: Cross domain iframe access using postmessage - access denied
body: <p>I'm using greasemonkey to try and automate filling in data. On the page where I want data pulled from I append a button to the document. This button creates a frame containing the website that I want to push the data to.</p>
  
  <p>From what I can see on SO and elsewhere, I <em>think</em> i'm supposed to be able to send information to an iframe by using postmessage. To do it i need to get the contentWindow for that frame.</p>
  
  <p>Now, when I create the frame, I can get access to the frame.contentWindow. If I attempt to get the contentWindow from within another function using document.getElementById("frameid").contentWindow I get "access denied".</p>
  
  <p>I've also stored the window reference in a global variable without problem when creating the iframe, but again if I try to access that variable from another function I get the same "access denied" error.</p>
  
  <p>I'm very new to all this so maybe I'm just doing something stupid, but can anyone clarify if this behaviour is normal? If it is normal then how can I use postmessage to send information to that iframe if I'm not able to get the contentWindow when I need it? :s</p>
  
  <p>Any help greatly appreciated. Thanks :)</p>