easyXDM 看起来有一个很棒的消息传输系统,GIT 文档中的桥接示例过于复杂,涉及 3 或 4 个 HTML 文件。可以在同一个域上使用子窗口和父窗口进行简单的窗口到窗口通信,兼容 IE8 等吗?
帮助需要一个 easyXDM 专家 - (此代码不起作用)
<! doctype html>
<html>
<head>
<!-- index.html -->
<title>postmessage Test</title>
<script type="text/javascript" src="easyXDM.debug.js" </
script>
<script type="text/javascript">
easyXDM.DomHelper.requiresJSON("json2.js"); </script>
<script type="text/javascript">
var target;
target = window.open("http://localhost/child.html",'popupWindow');
var socket = new easyXDM.Socket({
swf: "easyxdm.swf",
onMessage: function(message, origin){
alert("Received '" + message + "' from '" + origin + "'");
}
});
</script>
</head>
<body>
Parent Window<br/>
<button class="send-button" onclick="socket.postMessage('Msg from
Parent');">Post message</button>
</body>
</html>
<! doctype html>
<html>
<head>
<!-- child.html -->
<title>postmessage Child</title>
<script type="text/javascript" src="easyXDM.debug.js" </
script>
<script type="text/javascript">
easyXDM.DomHelper.requiresJSON("json2.js"); </script>
<script type="text/javascript">
var socket = new easyXDM.Socket({
remote: "http://localhost/",
swf: "easyxdm.swf",
onMessage: function(message, origin){
alert("Received '" + message + "' from '" + origin + "'");
}
});
</script>
</head>
<body>
Popup Window<br/>
<button class="send-button" onclick="socket.postMessage('Msg from
child');">Post message</button>
</body>
</html>