How do you set different height/width for iframe in fancybox V2?

后端 未结 1 1158
孤城傲影
孤城傲影 2021-01-14 07:42

I have been using Fancybox 1.3.4, and right there I have the dimensions of the iframe in the link itself.

Here is an example of how I have it

test.ht         


        
相关标签:
1条回答
  • 2021-01-14 08:37

    Set your html (with HTML5 DOCTYPE) like this:

    <a class="fancybox fancybox.iframe" data-width="675" data-height="470" href="test.html" >test</a>
    <a class="fancybox fancybox.iframe" data-width="400" data-height="200" href="test2.html" >test 2</a>
    

    (set width and height on the data- attributes for each element)

    then this script:

    $("a.fancybox").fancybox({
      fitToView: false,
      afterLoad: function(){
       this.width = $(this.element).data("width");
       this.height = $(this.element).data("height");
      }
     }); // fancybox
    

    should do the trick in fancybox v2.x

    0 讨论(0)
提交回复
热议问题