Javascript Fancybox内部Fancybox设置高度

Javascript Fancybox内部Fancybox设置高度,javascript,jquery,fancybox-2,Javascript,Jquery,Fancybox 2,我在主页上调用fancybox2。当fancybox iframe打开时,我在该页面中有一个链接将打开另一个fancybox iframe。现在的问题是: 当内容“更小”时,我无法让它移动到打开页面的顶部(查看示例站点上的源代码) 当内容较大时-我无法设置高度以避免滚动条 当我使用选择器时,如: parent.$('.SELECTOR').fancybox({…在这种情况下,我的“第一个”fancybox页面将关闭,我需要打开它,因为第二个“fancybox”将向“第一个”fancybox页面(

我在主页上调用fancybox2。当fancybox iframe打开时,我在该页面中有一个链接将打开另一个fancybox iframe。现在的问题是:

  • 当内容“更小”时,我无法让它移动到打开页面的顶部(查看示例站点上的源代码)

  • 当内容较大时-我无法设置高度以避免滚动条

  • 当我使用选择器时,如: parent.$('.SELECTOR').fancybox({…在这种情况下,我的“第一个”fancybox页面将关闭,我需要打开它,因为第二个“fancybox”将向“第一个”fancybox页面(表单驻留的地方)发送一些数据,最后在提交表单时,它将全部传输到“主页”

    我知道这很难理解,但这里有一个与示例的链接:

    那个么,如何动态设置第一个“fancybox”的高度呢


    谢谢!

    好的,我找到了这个解决方案,这是一个解决方案……更像是hack……但它可以在所有浏览器上工作……它实际上屏蔽了(不删除它->因为我需要将回调传递给它)第一个iframe(删除阴影、内容甚至关闭按钮),在关闭事件之后-它恢复第一个iframe:)

    哦,还有额外的“帖子”内容,因为整个网站实际上是通过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}
                }
        });
    
    和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;
    }  
    

    你用来打开fancybox的代码是什么?有一些选项可以用来设置最大高度和宽度。看一看示例+我不知道确切的高度-它是通过PHP动态生成的…我会尝试(在iframe1.html中)
    afterShow:function(){parent.$.fancybox.update()}
    no,这没有帮助:(