Hi,
I have the following scenario:
A .NET aps page (
www.mydotnet.com/easyXDM.asp) that opens a new page in a separate domain (
www.mychild.com/viewer). When the viewer page (in jsp) saves its data, the viewer (child) is required to send a message telling the parent page to refresh, in this case, it is the .NET asp page. Both pages are rendered or displayed in IE7 browser.
Since this a typical cross domain problem, I finally found the easyXDM framework to tackle this problem. So I have the following eashXDM scripted:
In the parent, I have this:
<script type="text/javascript" src="Scripts/easyXDM.js"></script>
<script type="text/javascript" src="Scripts/json2.js"></script>
<script type="text/javascript">
//parent
var socket = new easyXDM.Socket({
local: "name.html",
swf: "easyxdm.swf",
onMessage: function (message, origin) {
alert("This is a message: " + message + ". received from " + location);
window.location.reload();
}
});
</script>
In the child, I have this:
<script type="text/javascript" src="<%=request.getContextPath()%>/resources/js/easyXDM.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/resources/js/json2.js"></script>
<script type="text/javascript">
var socket = new easyXDM.Socket({
local: "name.html",
swf: "easyxdm.swf",
onMessage: function(message, origin){
alert("Received '" + message + "' from '" + origin + "'");
},
});
function sendMessageToParent() {
socket.postMessage("You need to refresh.");
};
</script>
.....
<body>
<form id="myform" name="myform" onsubmit="return sendMessageToParent();">
<label for="send_message"></label>
<input type="text" name="message" placeholder="Type your message here" id="message" />
<input type="submit" name="btn_submit" value="Send" id="btn_submit">
</form>
</body>
.....
The result was, communication between the two domain seemed to be working. However, when invoking the parent page to refresh, an action was triggered by sending the message to the parent domain, everything seemed to be happening on the child page side, such as the alert popup (from both parent and child pages), the page refresh, etc. Again, everything was taking place on the child page side, like all the actions, for some reasons, which I don't understand.
Did I configure the easyXDM socket correctly for both sides?
Please help!
Thanks,
DCWu