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

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.

-- 
Michael

Received on Tuesday, 5 January 2010 21:34:07 UTC