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

I use Fancybox 1.3.4, and right there I have iframe dimensions in the link itself.

Here is an example of how I him

test.html?width=675&height=470

When I click the link, fancybox will open an iframe with these sizes. I am trying Fancybox V2, but I am confused about how to set dimensions for iframes. I want each iframe to have different sizes. How should I do it?

+3
source share
1 answer

Install html (with HTML5 DOCTYPE) as follows:

<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 widthand heightin the attributes data-for each element)

then this is a 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

+1
source

All Articles