使用easyXDM调整IFrame大小 [英] IFrame resizing with easyXDM

查看:194
本文介绍了使用easyXDM调整IFrame大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将iFrame代码提供给客户,以便他们可以显示我网站上的动态内容。我希望生活在其页面上的iFrame能够调整大小以适应我的内容。我按照easyXDM网站上的说明进行操作,但也许我错过了一些东西。

I give my iFrame code to clients, so they can display the dynamic content from my site. I'd like the iFrame that lives on their page to resize to fit my content. I followed the instructions from the easyXDM site, but maybe I am missing something.

我没有收到任何错误,但iFrame保持默认高度(150px)。我给客户网站的代码是:

I don't get any errors, but the iFrame stays the default height (150px). The code I give my client site is :

<script src="http://test.pronetis.net/SNM.CMS/js/easyXDM/easyXDM.debug.js" type="text/javascript"></script>
<script type="text/javascript">
  var transport = new easyXDM.Socket({
    remote: "http://www.lipsum.com/",
    container: "container",
    onMessage: function (message, origin) {
      this.container.getElementsByTagName("iframe")[0].style.height = message + "px";
    }
  });
</script>
<div id="container"></div>

这是我要嵌入的文档的代码:

And this is the code that goes on the document I want to embed :

<script src="http://test.pronetis.net/SNM.CMS/js/easyXDM/easyXDM.debug.js" type="text/javascript"></script>
<script type="text/javascript">
  var socket = new easyXDM.Socket({
    onReady: function () { socket.postMessage(document.body.scrollHeight) }
  });
</script>

我希望有一些简单的我做错了...

I'm hoping there is something simple I'm doing wrong...

推荐答案

这很晚但你还没有添加任何备份传输方法。将 name.html 文件和 easyxdm.swf 文件放在您网站的根目录中,然后使用下面修改的代码

This very late but you haven't added any backup transport methods. Put the name.html file and easyxdm.swf file in the root of your website and then use the amended code below

客户网站

添加 remoteHelper 属性以指向 name.html ,并添加 swf 属性以指向 easyxdm.swf 文件。

Add the remoteHelper property to point to your name.html, and add the swf property to point to your easyxdm.swf file.

<div id="container"></div>
<script src="http://test.pronetis.net/SNM.CMS/js/easyXDM/easyXDM.debug.js" type="text/javascript"></script>
<script type="text/javascript">
  var transport = new easyXDM.Socket({
    remote: "http://www.lipsum.com/",
    remoteHelper: "http://www.lipsum.com/name.html",
    swf: "http://www.lipsum.com/easyxdm.swf",
    container: "container",
    onMessage: function (message, origin) {
      this.container.getElementsByTagName("iframe")[0].style.height = message + "px";
    }
  });
</script>

您的网站

添加属性本地以指向根目录中的name.html。

Add the property local to point to the name.html in your root.

<script type="text/javascript">
    var socket = new easyXDM.Socket({
        local: "name.html",
        onReady: function () {
            socket.postMessage(document.body.scrollHeight);
        }
    });
</script>

您还应确保您网站上的代码段位于网页的所有内容下方,因此最好放在< / body> 标签之前。

You should also ensure that the snippet on your website is underneath all of the content of your page, so it's probably best to put right before the </body> tag.

您可以下载easyxdm最新版本包含来自 name.html 和 easyxdm.swf -2.4.18.25.ziprel =nofollow>这里

You can download the easyxdm latest release that contains name.html and easyxdm.swf from here.

这篇关于使用easyXDM调整IFrame大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆