[whatwg] using postMessage() to send to a newly-created window
Darin Fisher
darin at chromium.org
Tue Jan 5 21:41:13 PST 2010
On Tue, Jan 5, 2010 at 9:34 PM, Michael A. Puls II <shadow2531 at gmail.com>wrote:
> On Tue, 05 Jan 2010 23:29:40 -0500, Dirk Pranke <dpranke at chromium.org>
> wrote:
>
> As an alternative, would it be possible to create an onChildLoad()
>> event in the parent so that the parent could reliably send a message
>> without needing the child's cooperation? These seems only marginally
>> better than having the child post to the parent, so it may not be
>> worth it ...
>>
>
> In Firefox, you can do stuff like this:
>
> var w = window.open("handler.html");
> w.addEventListener("DOMContentLoaded", function(e) {
> var targetWin = e.target.defaultView.
> targetWin.postMessage("Hello", "domain");
> }, false);
>
> But, I think that only works in Firefox. In Opera at least, I'm sure it
> doesn't work.
>
>
The same thing works fine in WebKit-based browsers as well. However, this
solution only works when the newly opened document is in the same origin as
the opener.
-Darin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20100105/a7f37503/attachment-0002.htm>
More information about the whatwg
mailing list