2012-02-06 69 views
0

如何将href“关闭”链接添加到Fancybox模式窗口?我想通过点击模式窗口中的href链接来关闭Fancybox,就像在Thickbox中完成一样。 我不想为此任务使用单独的JavaScript,而是想要修改Fancybox-1.3.4.js本身以获得此功能。如何将href“关闭”链接添加到Fancybox模式窗口?

从API的fancybox,下面的代码将做到这一点:

<a href="javascript:$.fancybox.close()">close</a> 

需要帮助和提示,如何实现这一目标。

回答

1

<a href="javascript:;" onclick="$.fancybox.close();">Close</a>

从fancybox.net看看在线 - 其中有一个关闭文本链接

1

答案被覆盖在提示的fancybox技巧&所以这里检查模式窗口例如: http://fancybox.net/blog

寻找第一个选择:

7. Custom title formating - lightbox style 
+0

我看了第7页“自定义标题格式 - 灯箱样式”:我可以在主jQuery.fancybox-1.3.4.js和css的末尾添加javascript代码吗? – 2012-02-06 22:41:36

+0

我看了第7页“自定义标题格式 - 灯箱样式”:我可以在主jquery.fancybox-1.3.4.js代码结束后直接添加此javascript代码吗? function formatTitle(title,currentArray,currentIndex,currentOpts){ return'

close' + (title && title.length ? '' + title + '' : '') + 'Image ' + (currentIndex + 1) + ' of ' + currentArray.length + '
'; 。 } $(”。tip7" )的fancybox({ \t 'showCloseButton' \t:假, \t 'titlePosition' \t \t: '内部', \t 'titleFormat' \t \t:formatTitle }); – 2012-02-06 22:54:13

+0

忽略这样不必要的元素是否正确? (因为我只需要关闭链接) function formatTitle(title,currentArray,currentIndex,currentOpts){ return'

close' + 'Image ' + '
'; } – 2012-02-06 22:55:06

0

试试这个。

<a href="javascript:void(0);" onclick="$.fancybox.close();">close</a>