Re: CfC: publish Last Call Working Draft of HTML5 Web Messaging; deadline March 14

On Mon, 7 Mar 2011, Steve Nester wrote:
> For example; in the example within the Cross-document 
> messaging>Introduction section, document A calls the function causing an 
> event to fire in document B.  Document B should either be able to call a 
> function causing an event to fire in document A OR document B should be 
> able to return data to document A in response to document A's function 
> call.

There are two ways to do that; you can either use postMessage() on the 
"source" attribute of the event (as the example in the spec does), or you 
can pass a MessagePort along with the message and then post a message back 
to the caller.

The first looks like this on B's side:
  e.source.postMessage('Hello', e.origin);

The second looks like this on B's side:

On A's side the former implies using a 'message' event handler on A's 
Window, the latter implies using "new MessageChannel()" to create the port 
and "onmessage" on the port that was not sent. There's an example of that 
in the Channel messaging section's introduction:

Ian Hickson               U+1047E                )\._.,--....,'``.    fL       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Tuesday, 8 March 2011 19:49:12 UTC