Does HTML5 support cross-windowing?

The spectrum says that I should use postMessage () for the window object. Mozilla says I can do this in the open () window too.

However, I took the Robert Nyman postMessage example and tried to get it to work through windows . However, neither IE10 nor Chrome seems to provide the postMessage function for a newly opened window.

var target = … // original declaration popoutbutton.onclick = function(evt) { realWin = window.open(iframeWin.frameElement.src, "window1", "width=600,height=400,status=yes,scrollbars=no,resizable=yes"); target = realWin; target.focus(); }; // …snip… target.postMessage(myMessage.value, expectorigin); // <-- fails because target.postMessage() is undefined 

Am I missing something or is this function just not there yet?

- update below -

Developer preview just doesn't seem like it. I tried again with the preview. IE10 (build 8250) likes pending. Thanks for your help!

+4
source share
2 answers

I can make it work in Chrome 15.0.874.121, although in your example you call target.postMessage before opening the window, although you missed some source code set by target .

You may also encounter the problem of calling postMessage before the content in the new window is loaded (or at least loaded enough for the event listener to be attached). Thus, an event can be triggered when it is not listening. You may need to add wait in this scenario to ensure that the window that has just opened is loaded.

In Internet Explorer 10, I get error message SCRIPT16388: Operation Aborted when I try to execute a script, even if I wait 10 seconds.

0
source

Source: https://habr.com/ru/post/1401388/


All Articles