postMessage between cross-domain windows not working in IE10 (it works for frames)

后端 未结 1 792
再見小時候
再見小時候 2021-01-13 01:15

I followed this tutorial http://davidwalsh.name/window-postmessage, and created cross domain messaging scripts which works in Chrome and Firefox but not in IE 10. Could anyo

相关标签:
1条回答
  • 2021-01-13 01:29

    IE does not support postMessage between cross-domain popup windows(eg:window.open). IE does support postMessage for embedded frames(eg:top.frames).

    So I end up by putting a frame into a dialog, pretending like a popup windows. eg:

    With the help of Jquery UI dialog

    <script>
    $("#dialog").dialog({
        autoOpen: false,
        modal: true,
        height: 300,
    weight: 400,
    });
    
    function openiframe(){
       $('#dialog').dialog('open');
    });
    </script>
    
    <p>At 120.0.0.211 server</p>
    <button type="button" onclick="openiframe()">send the message!</button>
    <div id="dialog">
       <iframe id="iframe" src="http://192.168.15.223/smallframe"></iframe>
    </div>
    

    It might be other solutions/technologies out there for commutation between cross-domain windows:

    1. Cross-Origin Resource Sharing (CORS) using Ajax.

    2. Using Webservice like REST, which actually is a server-to-server commutation, not a server-broswer-server struct anymore. But it is a way how we can send some message to another server. For some frameworks it is easy to setup REST eg: cakephp

    0 讨论(0)
提交回复
热议问题