Fancybox - 如何从网址加载图片?
问题描述:
我不知道如何可以创建与网址加载页面的图像的收藏夹链接 Fancybox - 如何从网址加载图片?
这里是我的代码,但它不工作:
$("a.picture").click(function() {
$.fancybox({
'padding' : 0,
'overlayShow' : false,
'transitionIn' : 'elastic',
'transitionOut' : 'elastic',
'titlePosition' : 'over',
'type' : 'image',
'titleFormat' : function(title, currentArray,
currentIndex, currentOpts) {
return '<span id="fancybox-title-over">' + (currentIndex +
1) + '/' + currentArray.length + (title.length ? ' ' +
title : '') + '</span>';
}
});
return false;
});
和HTML代码
<a class="picture" href="http://localhost/test/my_page.html" title="Picture Page">Link</a>
谢谢!
答
你有上面还脚本假设你有一个这样的HTML:
<a class="picture" href="images/picture.jpg">open image</a>
那么你也应该添加到您的脚本选项href
像
$("a.picture").click(function() {
$.fancybox({
'padding' : 0,
'overlayShow' : false,
'href': this.href, //<--LIKE THIS
// etc....
该选项将提供fancybox将加载图像的URL。
注意:提出问题是OK,我们很高兴提供帮助,但作为@ofir评论,你应该提供反馈,并接受他人提供这样的人会觉得积极地帮助你在未来的正确答案。
如果打开一个html页面,你应该设置''type':'iframe'而不是'type':'image' – JFK 2012-03-11 10:35:01