W3C home > Mailing lists > Public > whatwg@whatwg.org > December 2009

[whatwg] using postMessage() to send to a newly-created window

From: Dirk Pranke <dpranke@chromium.org>
Date: Mon, 21 Dec 2009 19:24:57 -0800
Message-ID: <3726d1bf0912211924x12a47744sa376379c6baa9336@mail.gmail.com>
Hi all,

In the course of testing something today, I attempted to create a
window and immediately post a message to it, and was surprised that it
didn't seem to work.


var w = window.open("http://x");
w.postMessage("hello, world", "*");

w never got the message - this seemed to be consistent across Safari,
Chrome, and FF (all I had installed on my Mac at the time, so
apologies to Opera, IE, and anyone else I've left out).

Is this supposed to work? If not, is there a reliable way for the the
source to know when it is safe to send a message to the target? The
only way I can think of is for the target to send a message back to
the source, which only works if the target can get a reference to the
source using window.opener, which may or may not be possible or
desirable ...

If this isn't supposed to work, can we state this explicitly in the spec?

-- dirk
Received on Monday, 21 December 2009 19:24:57 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:08:54 UTC