Hi Pamela,
I was not sending the origin/target, I think that was the problem =)
but now I've another problem with postmessage... =/
I'm trying to do the same thing yet, to send wave viewer to the local page
using postmessage... in the local page I try to assign the value to a global
variable in the eventlistener
but it's not working... simply it seems to be a local variable there.
here's a part of the code:
//Here I declare the variable
viewer = null;
//Here I try to assign them, and here it seems to work fine
window.addEventListener("message", onmessage, false);
function onmessage(e)
{
if (e.data != null && e.data != "undefined" )
{
viewer = e.data;
origin = e.origin;
}
}
//But here there's no value at all in viewer
function NewItem(wave_id)
{
alert(viewer);
}
On Wed, Feb 10, 2010 at 8:28 PM, pamela (Google Employee) <
[email protected]> wrote:
> (Note: I am also a postMessage noob).
>
> I believe that Chrome always gives that error/warning with
> postMessage, even when it works. Does the message not get received?
>
> Here's a postMessage demo my colleague recommended:
> http://html5demos.com/postmessage2
>
> You may want to test postMessage outside of the gadget environment
> first, for easier debugging.
>
> - pamela
>
>
> 2010/2/8 Daniel França <[email protected]>:
> > anyone?
> >
> > 2010/2/4 Daniel França <[email protected]>
> >>
> >> Hi, I'm really noob in this postmessage cross-iframe stuff,
> >> I tryed to do the following in XML:
> >>
> >>
> http://hosting.gmodules.com/ig/gadgets/file/117372586241155512680/openscape_tasks.xml
> >> and in my localhost javascript I tryed this:
> >> var viewer = new String();
> >> function TextChanged( wave_item, new_text )
> >> {
> >> if (new_text == '')
> >> window.location = 'clear/'+wave_item;
> >> else
> >> window.location = 'update/'+wave_item+'/'+escape(new_text);
> >>
> >>
> //wave.getState().submitDelta({'timestamp':currentTime,'author_id':viewer});
> >> }
> >> function NewItem(wave_id)
> >> {
> >> alert('NewItem');
> >> window.location = '
> http://cur3w12c.global-ad.net/new/'+wave_id+'/'+viewer;
> >> }
> >> function onmessage(e) {
> >> alert('LOCAL - Receiving data');
> >> viewer = e.data;
> >> }
> >>
> >> window.onload = function()
> >> {
> >> alert('LOCAL - AddListeners');
> >> window.addEventListener('message', onmessage, false);
> >>
> >> var win = parent.postMessage ? parent :
> >> (parent.document.postMessage ? parent.document : undefined);
> >> alert('LOCAL - Posting Ready of WIN: '+win);
> >> win.postMessage( 'ready' );
> >>
> >> /*if (typeof window.addEventListener != 'undefined') {
> >> window.addEventListener('message', onmessage, false);
> >> } else if (typeof window.attachEvent != 'undefined') {
> >> window.attachEvent('onmessage', onmessage);
> >> }*/
> >> }
> >>
> >> but I'm getting the error:
> >> Unsafe JavaScript attempt to access frame with URL
> >>
> https://u6s6tvnpihakquhfua1nc7jtklqur6v1-a-wave-opensocial.googleusercontent.com/gadgets/ifr?container=wave&v=4b97251b786c9b6159dc6592867b756&lang=en&country=ALL&view=default&url=http%3A%2F%2Fhosting.gmodules.com%2Fig%2Fgadgets%2Ffile%2F117372586241155512680%2Fopenscape_tasks.xml&libs=core%3Awave&mid=1049712407&nocache=0&mid=1049712407&parent=https://wave.google.com&wave=1&waveId=googlewave.com!w%2BkjuFEQZwA#rpctoken=-6036406246055971068&st=e%3DAHc%252FuhrXjU73cvin27UnLKvtjroSRAVon4xtFw%252F%252BBK7Vyx1K%252BV2K79P77UM2PzxLi96I%252FeRQGlHDa04XNxz0U6FdXHg00CaZlk0zepJwi2O9FCKFYhbKpjtyHFMHq36iI%252BtW2TAourkI3fV4WAkSQErgh5u0pVtCgWVvOHL6GEtqFT0%252BGTVZrfsbmHlREYu%252Fx7Tjb%252BqD29NGhAP6d5lnPXJ%252FA07xmQiNgILGRn3Q0eU969Cefict2kJwxiI3Xd4RSSl6AitFjPhCLLYEgY%252Bh0vi9DRbaSFaS7duJDvmqexcnqHNrnMJjEt0CjZLRuedeQitokkj%252B%252FXuB%26c%3Dwave
> >> from frame with URL http://cur3w12c.global-ad.net/kjuFEQZwA/. Domains,
> >> protocols and ports must match.
> >> I can't realize what's the right way to do that.
> >>
> >> On Wed, Feb 3, 2010 at 9:53 PM, pamela (Google Employee)
> >> <[email protected]> wrote:
> >>>
> >>> Ah, I see. I recommend including the local website as an iframe, and
> >>> communicating with it from the main gadget spec. Since HTML5's
> >>> cross-iframe postMessage method works in all Wave-supported browsers,
> >>> you can use postMessage to communicate from the gadget to the iframe
> >>> and vice versa.
> >>>
> >>> - pamela
> >>>
> >>> 2010/2/4 Daniel França <[email protected]>:
> >>> > Hi Pamela, that's because I wanna load an "web site" hosted local and
> >>> > this
> >>> > site should receive events from Wave, update database, etc... how can
> I
> >>> > do
> >>> > that?
> >>> >
> >>> > On Wed, Feb 3, 2010 at 9:14 PM, pamela (Google employee)
> >>> > <[email protected]> wrote:
> >>> >>
> >>> >> Hi Daniel -
> >>> >>
> >>> >> We discourage the use of content type="url" gadgets when creating
> Wave
> >>> >> gadgets, as it makes pulling in the various "features" tricky. You
> >>> >> have to separately pull in the gadgets API, wave API, etc.
> >>> >> I recommend that you use content type="html" instead, and you'll
> find
> >>> >> development much easier.
> >>> >>
> >>> >> - pamela
> >>> >>
> >>> >> On Feb 4, 8:20 am, Daniel França <[email protected]> wrote:
> >>> >> > more info, this is how I load another page:
> >>> >> >
> >>> >> > wave_id = wave.getWaveId().split('+')[1];
> >>> >> > new_url = 'http://cur3w12c.global-ad.net/'+wave_id;
> >>> >> > window.location = new_url
> >>> >> >
> >>> >> > 2010/2/3 Daniel França <[email protected]>
> >>> >> >
> >>> >> >
> >>> >> >
> >>> >> > > and wave.getViewer() wave.getHost wave.getWaveId, etc return
> NULL
> >>> >> > > in
> >>> >> > > this
> >>> >> > > another page
> >>> >> >
> >>> >> > > 2010/2/3 Daniel França <[email protected]>
> >>> >> >
> >>> >> > > Hi again,
> >>> >> > >> I'm trying todo the following scenario:
> >>> >> >
> >>> >> > >> I've a public XML hosted at
> >>> >> >
> >>> >> > >>
> >>> >> > >> >> >>
> http://hosting.gmodules.com/ig/gadgets/file/117372586241155512680/ope...
> >>> >> > >>
> >>> >> > >>
> >>> >> > >> <
> http://hosting.gmodules.com/ig/gadgets/file/117372586241155512680/ope..
> .>this
> >>> >> > >> XML loads a page with dynamic parameters (the Wave ID)
> >>> >> > >> in this other page there's some javascipt to interact, and call
> >>> >> > >> some
> >>> >> > >> wave
> >>> >> > >> methods, as this in other page I think the <Require
> >>> >> > >> feature="wave" />
> >>> >> > >> does
> >>> >> > >> not work for it, so I included the wave javascript manually:
> >>> >> > >> *<script src="https://wave-api.appspot.com/public/wave.js"
> >>> >> > >> type="text/javascript"></script>*
> >>> >> > >> *
> >>> >> > >> *
> >>> >> > >> It seems to be ok for wave methods, but I still get an
> exception
> >>> >> > >> from
> >>> >> > >> gadgets object in
> >>> >> >
> >>> >> > >> *gadgets.util.registerOnLoadHandler(init);** *
> >>> >> > >> *
> >>> >> > >> *
> >>> >> > >> *The errro: gadgets is not defined*
> >>> >> >
> >>> >> > >> What I need to include to get this work?
> >>> >>
> >>> >> --
> >>> >> You received this message because you are subscribed to the Google
> >>> >> Groups
> >>> >> "Google Wave API" group.
> >>> >> To post to this group, send email to
> [email protected].
> >>> >> To unsubscribe from this group, send email to
> >>> >> [email protected]<google-wave-api%[email protected]>
> .
> >>> >> For more options, visit this group at
> >>> >> http://groups.google.com/group/google-wave-api?hl=en.
> >>> >>
> >>> >
> >>> > --
> >>> > You received this message because you are subscribed to the Google
> >>> > Groups
> >>> > "Google Wave API" group.
> >>> > To post to this group, send email to
> [email protected].
> >>> > To unsubscribe from this group, send email to
> >>> > [email protected]<google-wave-api%[email protected]>
> .
> >>> > For more options, visit this group at
> >>> > http://groups.google.com/group/google-wave-api?hl=en.
> >>> >
> >>>
> >>> --
> >>> You received this message because you are subscribed to the Google
> Groups
> >>> "Google Wave API" group.
> >>> To post to this group, send email to [email protected].
> >>> To unsubscribe from this group, send email to
> >>> [email protected]<google-wave-api%[email protected]>
> .
> >>> For more options, visit this group at
> >>> http://groups.google.com/group/google-wave-api?hl=en.
> >>>
> >>
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Google Wave API" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]<google-wave-api%[email protected]>
> .
> > For more options, visit this group at
> > http://groups.google.com/group/google-wave-api?hl=en.
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Wave API" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-wave-api%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-wave-api?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"Google Wave API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-wave-api?hl=en.