Re: sameOriginTransport: undefined is not a function error.

219 views
Skip to first unread message

Øyvind Sean Kinsey

unread,
Jun 4, 2012, 8:44:38 PM6/4/12
to eas...@googlegroups.com
The architecture of easyXDM doesn't allow you to mess with the url of the iframe, whether by navigating it from within the iframe or by setting its src.

So, if you really want to reload the iframe, then you need to call `.destroy()` on the socket/rpc when 'hiding' it, and then recreate the socket/rpc when 'showing' it again. 
But if you merely want to hide/show it, then you should simply move it off/on screen using the style of either the iframe or the container.

Øyvind Sean Kinsey
San Francisco, CA


On Mon, Jun 4, 2012 at 4:47 PM, boertel <b...@punchtab.com> wrote:
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



Reply all
Reply to author
Forward
0 new messages