用jquery设置fancybox高度 [英] set fancybox height with jquery

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

问题描述

我想在我的页面上显示一个fancybox,显示一个iframe,其中包含另一个具有动态高度的域的来源(因为在iframe中我会转到不同的页面或者可能有一些动态内容)。我也可以访问其他域名的代码。所以我可以使用postMessage将iframe的源高度发送到我的页面。但我似乎无法想象如何通过代码更改fancybox的高度。

I want to show a fancybox on my page displaying an iframe with a source of another domain that has dynamic height (since within the iframe I'll go to different pages or might have some dynamic content). I have access to the other domain's code as well. So I can use postMessage to send the iframe's source's height to my page. But I can't seem to figure how to change the fancybox's height through code.

我尝试设置包含iframe的所有div的高度,包括iframe本身:

I tried setting the height of all the divs that contain the iframe, including the iframe itself:

document.getElementById('fancybox-frame').height = parseInt(height);
document.getElementById('fancybox-content').height = parseInt(height);
document.getElementById('fancybox-outer').height = parseInt(height);
document.getElementById('fancybox-wrap').height = parseInt(height);

我知道我正在通过所有权利,因为它完全适用于直接集成iframe。

and I know that I'm getting the height through all right since it works perfectly on a directly integrated iframe.

任何人都有任何想法?

谢谢

编辑:
我也试过$ .fancybox.update(),但我不确定如何实现:

I also tried $.fancybox.update() but I'm not really sure on how to implement that:

$.fancybox({
'height': height
});
$.fancybox.update();


推荐答案

找到它,你必须改变以下属性

Found it, you have to change following attributes

document.getElementById('fancybox-content').style.height = parseInt(height) + 'px';
document.getElementById('fancybox-frame').height = parseInt(height);

这篇关于用jquery设置fancybox高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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