0

我尝试了很多解决方案,但在我的网站上没有任何效果。

现在我使用:

<iframe src="http://www.travelstoremaker.com/ibe/turismoin/porch?command=flights" frameborder="0" marginwidth="0" marginheight="0" width="906" height="5000"></iframe>

你可以在这里看到它:http: //turismo-in.it/voli-in-italia/

现在我发现了这个:

    var transport = new easyXDM.transport.BestAvailableTransport({
    local: "../hash.html",
    remote: "http://provider.easyxdm.net/example/resized_iframe.html",
    container: document.getElementById("element_that_should_contain_the_frame"),
    onMessage: function(message, origin){
        this.container.getElementsByTagName("iframe")[0].style.height = message + "px";
    }
});

然后将以下内容放在内容之后的 iframe 正文中

    var transport = new easyXDM.transport.BestAvailableTransport({}, function(){
    transport.postMessage(document.body.scrollHeight);
});

但是怎么做呢?我必须在哪里添加它?有用?!有一种解决方案可以在跨域中自动调整 iframe 的高度吗?

PS 我无法更改 iframed 页面中的代码,但只能在我的网站中更改

4

1 回答 1

0

如果无法更改 iframed 页面上的代码,则无法获得所需的高度。我尝试了很多解决方案,唯一一个我工作过的就是使用 post message。但是,您必须能够从 iframe 发布消息。

于 2013-02-07T17:34:20.047 回答