Fancybox - declaring size in link

痴心易碎 提交于 2020-01-06 02:40:08

问题


Due to the system i'm having to build a site in templates are extremely restrictive so I don't have much control.

My question is:

Is it possible with fancybox to set the width and height in the link?

e.g.

<a href="iframelocation" class="fancybox 480 320">Click here"</a>

Thanks in advance.

PVS


回答1:


You could store the values in data- attributes. (assuming you are using jQuery 1.4.3 or greater)

<a href="iframelocation" class="fancybox" data-width="480" data-height="320">Click here"</a>

$("a.fancybox").each(function(){
   var $a = $(this);
   var h = $a.data("height")
   var w = $a.data("width");
   $a.fancybox({
            'width' : w, 
            'height': h
   });
});



回答2:


I'd recommend using HTML5 data-* attributes.

<a href="iframelocation" class="fancybox" data-width="480" data-height="320">Click here"</a>


来源:https://stackoverflow.com/questions/5378565/fancybox-declaring-size-in-link

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!