iframe中的自动高度内容

iframe中的自动高度内容

本文介绍了iframe中的自动高度内容(CORS?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在与客户合作。他们的网页使用此DOCTYPE

I am working with a client. Their webpage is using this DOCTYPE

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

我需要将内容传送到他们网站上的网页。我的内容如下所示:

I need to deliver content to pages on their site. My content looks like this

    <div style="height:1000px">
    <iframe frameborder="0" src="..." width="550" height="220"></iframe>
    <br/>
    <br/>
    <iframe frameborder="0" src="..." width="550" height="220"></iframe>
    </div>

我可以通过给客户端一两行css来放置内容,目前和iframe:

I can place the content on the clients page by giving them a couple of lines of css, and, currently, and iframe:

<style>
.iframecontent
{
    background-color:blue;
    position: relative;
height: 100%;
width: 100%
}
</style>

<iframe class="iframecontent" frameborder="0" src="..." width="100%" scrolling="no"> </iframe>

因为内容的高度是动态的,我不能为客户端提供特定高度需要它伸展。

Because the height of the content is dynamic, I cannot provide a specific height to the client - instead I need it to stretch.

我已经阅读了很多帖子,但仍然不确定最好的方式做到这一点。可能CORS?还有其他吗?

I've read many posts, but am still not sure of the best way to do this. Possibly CORS? Something else?

这里有一个解决方案: - 它在同一个域中工作,但对于跨域谈话,它依赖于PostMessage,这是一个HTML 5事

Here is one solution offered: http://sly777.github.com/Iframe-Height-Jquery-Plugin/ - it works on the same domain, but for cross-domain talk it relies on PostMessage which is an HTML 5 thing.

我尝试过,但无法使其正常工作。

I've tried http://blog.johnmckerrell.com/2006/10/22/resizing-iframes-across-domains/ but have not be able to get it to work.

我可能只是让客户端将框架设置为1500px,以便它适合我选择的内容,并与它完成,但有更好的方法吗? p>

I might just get the client to set the frame to 1500px so that it should fit whatever I choose to be in the content and be done with it, but is there a better way?

推荐答案

我更新了你试过的插件(),我添加了如何使用这个插件跨域修复的教程。我希望它有帮助。

I updated my plugin that you tried (http://sly777.github.com/Iframe-Height-Jquery-Plugin/) and i added tutorial how to use this plugin for cross-domain fix. I hope it helps.

这篇关于iframe中的自动高度内容(CORS?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 11:37