1
votes

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.

From what I can see on SO and elsewhere, I think 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.

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".

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.

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

Any help greatly appreciated. Thanks :)

1

1 Answers

0
votes

Last week, I had exactly same problem and I fixed it regarding related Mozilla's Developer Document. https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage

And here is an example: https://gist.github.com/nesimtunc/cbfee61071ab46459b5c