easyXDM看起来有一个很好的消息传输系统,GIT文档中的桥接示例过于复杂,涉及3或4个HTML文件。 是否可以进行简单的Window to Window通信,同一域上的子窗口和父窗口,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>