W3C home > Mailing lists > Public > public-webapps@w3.org > January to March 2011

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

From: Ian Hickson <ian@hixie.ch>
Date: Tue, 8 Mar 2011 19:48:43 +0000 (UTC)
To: Steve Nester <steve@sahfor.com>
cc: public-webapps@w3.org
Message-ID: <Pine.LNX.4.64.1103081944080.16784@ps20323.dreamhostps.com>
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:
  e.ports[0].postMessage('Hello');

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:

   http://www.whatwg.org/specs/web-apps/current-work/complete/web-messaging.html#introduction-10

HTH,
-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
Received on Tuesday, 8 March 2011 19:49:12 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:43 GMT