[英]Set fancybox height to Iframe body height
還有許多其他具有類似標題的流程。 我已經嘗試了所有流程,但沒有一個起作用。
Register.php具有表格和相關的js文件。 注冊后,“謝謝”頁面也會以相同的高度顯示。
的HTML
<a class="reg-popup fancybox.iframe" data-fancybox-type="iframe" href="register.php"> Register </a>
jQuery的
jQuery(document).ready(function() {
jQuery(".reg-popup").fancybox({
fitToView : true,
type : 'iframe',
autoSize : false,
minWidth : '43%',
maxWidth : '50%',
maxHeight : '90% ',
width : 'auto',
height : 'auto',
autoDimensions : true,
html : true,
beforeShow: function(){
this.width = (jQuery('.fancybox-iframe').contents().find('body').width());
this.height = (jQuery('.fancybox-iframe').contents().find('body').height());
},
'afterClose':function () {
window.location.reload();
},
onUpdate : { autoHeight: true},
helpers : {
overlay : {closeClick: false}
}
});
});
如果iframe內容位於其他子域/域上,則需要使用postMessage,以便兩者進行通信。 您將需要訪問iframe中的內容,以便可以傳達文檔高度。
嘗試將nextSpeed和prevSpeed設置為0。我不確定您是否需要在此處使用括號(jQuery('。fancybox-iframe')。contents()。find('body')。width()),但它們會無害。
jQuery(document).ready(function() {
jQuery(".reg-popup").fancybox({
fitToView : true,
type : 'iframe',
autoSize : false,
minWidth : '43%',
maxWidth : '50%',
maxHeight : '90% ',
width : 'auto',
nextSpeed: 0, //add this line
prevSpeed: 0, //and this line
height : 'auto',
autoDimensions : true,
html : true,
beforeShow: function(){
this.width = (jQuery('.fancybox-iframe').contents().find('body').width());
this.height = (jQuery('.fancybox-iframe').contents().find('body').height());
},
'afterClose':function () {
window.location.reload();
},
onUpdate : { autoHeight: true},
helpers : {
overlay : {closeClick: false}
}
});
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.