2013-02-15 114 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; 
}