是否有跨域iframe高度自动调整器工作? [英] Is there a cross-domain iframe height auto-resizer that works?

查看:115
本文介绍了是否有跨域iframe高度自动调整器工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了几个解决方案,但没有成功。

I tried a few solutions but wasn't successful. I'm wondering if there is a solution out there preferably with an easy-to-follow tutorial.

推荐答案

你有三种选择:

这是一个简单的库,用于保持iFrames的内容大小。它使用PostMessage和MutationObserver API,后备为IE8-10。它还有内容页面的请求的选项,要求包含iFrame是一定的大小,也可以关闭iFrame时,你做它。

This is a simple library for keeping iFrames sized to their content. It uses the PostMessage and MutationObserver APIs, with fall backs for IE8-10. It also has options for the content page to request the containing iFrame is a certain size and can also close the iFrame when your done with it.

http://davidjbradshaw.github.io/iframe-resizer/

Easy XDM使用一系列技巧在多个浏览器中启用不同窗口之间的跨域通信,用于iframe调整大小:

Easy XDM uses a collection of tricks for enabling cross-domain communication between different windows in a number of browsers, and there are examples for using it for iframe resizing:

http://easyxdm.net/wp/2010/03/17/resize-iframe-based-on-content/

http://kinsey.no/blog/index.php/2010 / 02/19 / resizing-iframe-use-easyxdm /

Easy XDM使用 PostMessage 在现代浏览器和基于Flash的解决方案作为旧版浏览器的后备。

Easy XDM works by using PostMessage on modern browsers and a Flash based solution as fallback for older browsers.

另请参见这个线程在Stackoverflow (还有其他人,这是一个常见的问题)。此外, Facebook似乎使用类似的方法

See also this thread on Stackoverflow (there are also others, this is a commonly asked question). Also, Facebook would seem to use a similar approach.

另一种选择是将iframe高度发送到您的服务器,然后从该服务器使用JSONP轮询父网页(或使用长轮询如果可能)。

Another option would be to send the iframe height to your server and then poll from that server from the parent web page with JSONP (or use a long poll if possible).

这篇关于是否有跨域iframe高度自动调整器工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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