简体   繁体   English

Fancybox内部的Fancybox设置高度

[英]Fancybox inside fancybox setting heights

I have main page where I am calling fancybox2. 我在主页上呼叫fancybox2。 When fancybox iframe opens, I have a link inside that page that will open another fancybox iframe. 当fancybox iframe打开时,我在该页面内有一个链接,该链接将打开另一个fancybox iframe。 Now issue is: 现在的问题是:

  1. When content is "smaller" I can't get it to move to the top of the opened page (take a look at source on example site) 当内容“较小”时,我无法将其移动到打开的页面的顶部(请查看示例网站上的源代码)

  2. When content is larger - I can't set height in order to avoid scrollbars. 当内容较大时-我无法设置高度以避免滚动条。

When I use selector like: parent.$('.SELECTOR').fancybox({ ...in that case my "first" fancybox page will close, and I need that open as second "fancybox" will send some data to "first" fancybox page (where form resides) and finally once when that form is submitted it's all transferred to "main page"... 当我使用如下选择器时:parent。$('。SELECTOR')。fancybox({...在这种情况下,我的“第一个” fancybox页面将关闭,而我需要打开,因为第二个“ fancybox”会将一些数据发送到“第一个” fancybox页面(表单所在的地方),最后一次提交表单时,所有内容都将转移到“主页” ...

I know it is difficult to understand, but here is a link with example: 我知道很难理解,但这是示例的链接:

http://wwiz.webatu.com/ http://wwiz.webatu.com/

So how to set height of first "fancybox" dynamically ? 那么如何动态设置第一个“ fancybox”的高度呢?

Thanks ! 谢谢 !

OK, I figured out this and here is solution.... more like hack... but it works on all browsers... And what this does: it actually MASKS (doesn't remove it -> because I need to pass callbacks to it) first iframe (removing shadows, content even close button) and after close event - it restores the first iframe :) 好的,我找到了解决方案,这是解决方案。。。更像是hack。。。它可以在所有浏览器上使用。。。。。。。。。。它实际上是掩盖(不删除它->因为我需要传递回调)第一个iframe(删除阴影,内容甚至关闭按钮),并且在close事件之后-它还原第一个iframe :)

Oh, there is additional "post message" stuff since whole site is actually loaded via iframe (cross-domain stuff) and this is solution that works in regular iframe which loads fancybox1 that loads fancybox2 with popup... anyway it's too complicated to explain, and anybody who seeks for viable solution - here you go: 哦,还有附加的“发布消息”内容,因为整个网站实际上是通过iframe加载的(跨域内容),并且这是在常规iframe中可以加载fancybox1并通过弹出窗口加载fancybox2的解决方案...无论如何,它太复杂了,难以解释,以及任何寻求可行解决方案的人-在这里,您可以:

        $('.addmember').fancybox({
            openEffect : 'elastic',
            closeEffect : 'elastic',
            fitToView : false,
            nextSpeed: 0, //important
            prevSpeed: 0, //important
            beforeShow: function(){
            $_returnvalue = false;
             this.width = ($('.fancybox-iframe').contents().find('#popup-add-member').width());
             this.height = ($('.fancybox-iframe').contents().find('#popup-add-member').height());
     var ifrchild = $('.fancybox-iframe').contents().find('#popup-add-member').height()+60;
     parent.$('.fancybox-skin').attr('style', function(i,s) { return s + 'height: '+ifrchild+'px;' });
     parent.$('.fancybox-inner').attr('style', function(i,s) { return s + 'height: '+ifrchild+'px;' });
     $('.fancybox-wrap').attr('style', 'top: 15px !important;');
     parent.$('.fancybox-close').addClass("fancynodisplay");
     parent.$('.fancybox-overlay').addClass("fancybox-hidescroll");
     $('.fancybox-overlay').addClass("fancybox-hideoverlay");
     $('.fancybox-overlay').addClass("fancybox-hidescroll");
     $('.fancybox-skin').addClass("fancybox-hideshadow");
     parent.$('.fancybox-skin').addClass("fancybox-hideshadow");
     parent.$('.fancybox-skin').addClass("fancybox-hideskin");
     $('#hide-on-open').attr('style', 'display:none;');
            }, 
            afterShow: function(){
     },
            afterClose : function() {
                $('#hide-on-open').attr('style', 'display:block;');
                var ifrmain = $('#schedule-members').height();
                parent.$('.fancybox-skin').attr('style', function(i,s) { return s + 'height: '+ifrmain+'px;' });
      parent.$('.fancybox-inner').attr('style', function(i,s) { return s + 'height: '+ifrmain+'px;' });

                parent.$('.fancybox-close').removeClass("fancynodisplay");
                parent.$('.fancybox-overlay').removeClass("fancybox-hidescroll");
                $('.fancybox-overlay').removeClass("fancybox-hidescroll");
                parent.$('.fancybox-skin').removeClass("fancybox-hideskin");
                        if ($_returnvalue != false && $_returnvalue.response == "OK" )
                        {
                            // MY CALLBACK FUNCTIONS 
                        }

                        window.top.postMessage($('#wrap').height()+80, 'myiframe');
            },
            onUpdate : { autoHeight: true},
            beforeLoad :    function() {
     var ifrchild = $('.fancybox-iframe').contents().find('#popup-add-member').height()+60;
     window.top.postMessage(ifrchild, 'myiframe');                  
            },
            helpers : {
                  overlay : {closeClick: false}
            }
    });

And CSS to make this happen: 和CSS可以做到这一点:

.fancybox-close.fancynodisplay {
height: 0px !important;
width: 0px !important;
display: none !important;}
.fancybox-overlay.fancybox-hidescroll {
overflow: hidden !important;
}
.fancybox-opened .fancybox-skin.fancybox-hideshadow {
-webkit-box-shadow: none !important;
   -moz-box-shadow: none !important;
        box-shadow:none !important;}
.fancybox-hideskin {
background: none repeat scroll 0 0 rgba(255, 255, 255, 0) !important;
position: relative !important;
text-shadow: none !important;
}
.fancybox-hideoverlay {
background: none;
}  

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM