2013-02-15 124 views
0

我有我打电话fancybox2主页。当fancybox iframe打开时,我在该页面中有一个链接,将打开另一个fancybox iframe。现在的问题是:fancybox内fancybox设置高度

  1. 当内容是“小”,我不能把它移动到打开页面的顶部(看看源例如网站)

  2. 当含量更大 - 我无法设置高度以避免滚动条。

当我使用像选择:。 父$(“选择器”)的fancybox({...在这种情况下,我的‘第一次’的fancybox页面将关闭,我需要一个开放的第二个“ fancybox“将发送一些数据到”第一“fancybox页面(表单驻留),最后一次当表单提交时,它全部转移到”主页“...

我知道这很难理解,但在这里以实例的链接:

http://wwiz.webatu.com/

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

谢谢!

+0

什么是你用它来打开你的fancybox代码?有一些选项可以用来设置最大高度和宽度。 – 2013-02-15 15:30:58

+0

看看示例+我不知道确切的高度 - 它是通过PHP动态生成的... – Peter 2013-02-15 15:36:12

+0

我会尝试(在iframe1.html中)afterShow:function(){parent。$。fancybox.update() }' – JFK 2013-02-15 17:45:32

回答

0

好的,我想出了这个,这里是解决方案....更像是破解...但它适用于所有浏览器......而且它的作用:它实际上是MASKS(不会删除它 - >因为我需要通过回调)第一个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; 
}