Has anyone ever tried using postMessage() in a greasemonkey script
before that could suggest anything or give an example on how it was
used properly with greasemonkey? I know how to use it properly outside
of greasemonkey but for some reason it won't in a greasemonkey script.

Any response would be helpful!
Thanks,
slickplaid

On Oct 28, 7:46 pm, slickplaid <slick...@slickplaid.net> wrote:
> I'm attempting to write a greasemonkey script that brings up a
> messaging window in an iframe that is on a different domain. To send
> the information to that iframe from the parent window, I'm trying to
> use the postMessage() function, but for some reason I can't get it to
> send and/or receive to and from the iframe.
>
> In the greasemonkey script I create a new iframe (I'm using jquery):
>
>         $('body').append('<iframe src="http://mysite.com/api.php"; id="com"></
> iframe>');
>
> In the api.php, I have:
>
>         window.addEventListener('message', function(e){
>                 document.getElementById('test').textContent = e.domain+' said:
> '+e.data;
>         }, false);
>
> Now, further down in the greasemonkey script I try and send a simple
> message:
>
>         window.parent.frames[0].postMessage('hello world', 'http://
> mysite.com');
>
> It doesn't register and it doesn't throw any errors to let me know why
> it isn't sending. I type the above javascript into FireBug and it
> displays perfectly in the iframe and registers that it was sent. Why
> doesn't this work the same in Greasemonkey? Is there a work-around or
> am I calling the window improperly from the chrome or where ever
> greasemonkey is relative to the iframe?
>
> I'm really at a loss to exactly why it won't work. Any help would be
> appreciated!
>
> Thanks,
> slickplaid
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"greasemonkey-users" group.
To post to this group, send email to greasemonkey-users@googlegroups.com
To unsubscribe from this group, send email to 
greasemonkey-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/greasemonkey-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to