javascript - window.postMessage internet explorer 11 support -
i attempting use postmessage()
send data new window spawned parent window. postmessage()
works fine in chrome/firefox internet explorer seems choking on addeventlistener
, no data being sent new page.
i understand ie should use attachevent
have implemented, child page supports addeventlistener
, parent page not while referencing child.
parent:
var newtab = window.open('community_printerfriendlyeligibility'); if (newtab.addeventlistener) { console.log('add1'); newtab.addeventlistener('load', function() { console.log('add2'); newtab.postmessage(data,'*'); }); } else if (newtab.attachevent) { console.log('attach1'); newtab.attachevent('load', function() { console.log('attach2'); newtab.postmessage(data,'*'); }); }
child:
if (window.addeventlistener) { console.log('add'); window.addeventlistener('message', function(event) { //process chrome }, false); } else if (window.attachevent) { console.log('attach'); window.attachevent('message', function(event) { //process ie }); }
debug in ie:
parent window: attach1 child window: add
debug in chrome:
parent window: add1 add2 child window: add
so in ie, parent reference child window not have addeventlistener
child window accepts addeventlistener
afaik it's not needed in ie11: http://caniuse.com/#search=addeventlistener
just tested in ie11 , can confirm uses addeventlistener.
are emulating ie8 in parent page? use attach.
the new window revert default (edge), use add.
Comments
Post a Comment