簡體   English   中英

用jQuery設置fancybox的高度

[英]set fancybox height with jquery

我想在頁面上顯示一個花哨框,其中顯示一個iframe,該iframe帶有另一個具有動態高度的域的源(因為在iframe中,我將轉到其他頁面,或者可能包含一些動態內容)。 我也可以訪問其他域的代碼。 因此,我可以使用postMessage將iframe的源高度發送到我的頁面。 但是我似乎無法弄清楚如何通過代碼來改變fancybox的高度。

我嘗試設置所有包含iframe的div的高度,包括iframe本身:

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上完美運行。

任何人有任何想法嗎?

謝謝

編輯:我也嘗試$ .fancybox.update(),但我不確定如何實現:

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

您是否嘗試過內置的$.fancybox.update()方法? 文檔建議(在API方法下)此方法應提供您正在尋找的功能。

找到它,您必須更改以下屬性

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM