- 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
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 UTC