自动调整 iFrame 高度 [英] Auto-Fit iFrame Height

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

问题描述

现在,我有一个从外部页面读取的 jQuery UI 弹出对话框.此页面通过 flowplayer 从另一个具有视频的外部读取.

我使用 iframe 在第一个中嵌入视频:

<iframe id="iframeDonkey" width="100%" height="496" src="../../../../video/donkey-2009-02-23.html" frameBorder="0"></iframe>

100% 的宽度似乎没问题,但 100% 的高度不起作用.有没有办法解决这个问题?

在何处以及如何嵌入代码以及 ID 内容.请任何人帮忙?

解决方案

如果您想使用 100% 之类的值而不是像素值,则必须使用某种 JavaScript 来动态调整 iframe 的高度.

不幸的是,我的理解是您无法动态更改 iframe 的高度,该 iframe 指向的域与您自己的域不同.

来自代码丢失:

<块引用>

jQuery:自动 iFrame 高度

请注意,这个 jQuery autoHeight 插件不适用于从不同域或远程位置访问内容的 iFrame,因为由于 JavaScript 安全限制,无法从当前域访问源自不同域的窗口对象.

Right now, I have a jQuery UI pop-up dialog that reads from an external page. This page reads from another external that has a video via flowplayer.

I'm using iframe to embed the video in the first:

<div id="donkeyVideo">
<iframe id="iframeDonkey" width="100%" height="496" src="../../../../video/donkey-2009-02-23.html" frameBorder="0"></iframe>
</div>

The width seems all right with 100%, but 100% height doesn't work. Is there a way around this?

Where and how do I embed the code, as well as the ID stuff. Please anyone, help?

解决方案

You'll have to use some sort of JavaScript to dynamically adjust the height of an iframe if you want to use something like 100% rather than a pixel value.

Unfortunately, my understanding is that you cannot dynamically alter the height of an iframe that is pointing to a different domain than your own.

From lost-in-code:

jQuery : Auto iFrame Height

Please note that this jQuery autoHeight plugin will not work with iFrames accessing content from a different domain or remote location since the window object originating from a different domain cannot be accessed from the current one due to JavaScript security restrictions.

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

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