On my page, I'm using easyXDM to create an iframe that I can show and hide.
// Create the iframe the first time I want to show the iframe
socket = new easyXDM.Socket({
remote: url,
container: container,
props: props,
onReady: function () {
obj.iframe_url = document.getElementById('iframe').getAttribute('src');
},
onMessage: function (message, origin) {
/* ... */
}
});
// hide the iframe
document.getElementById('iframe').setAttribute("src", obj.empty_url);
// show the iframe for the second time:
document.getElementById('iframe').setAttribute("src", obj.iframe_url); // obj.iframe_url was defined on the onReady
When it's using the postMessageTransport method, it's working fine, no issue.
When it's using the sameOriginTransport method,
- the first time I open the iframe is working fine (create the iframe)
- but the second time (create the iframe > hide > show) it's failing and I've got this error: "undefined is not a function"
After a little bit of investigation, I discovered that the EasyXDM.Fn.get(name, del) was deleting a sort of callback:
// line 1526 on the debug.js file:
send = getParentObject().Fn.get(config.channel, true)(function(msg){
pub.up.incoming(msg, targetOrigin);
});
If I switch true to false, I've got the same behavior as the postMessageTransport method.
Am I doing something wrong? It's weird that the behavior is different between postMessage (= cross domain) and sameOrigin.
Thanks,
Ben