Hyperlink 将标题转换为链接不会';t在灯箱2.51中工作
在从下载的Lightbox 2.51中,将标题转换为链接不起作用Hyperlink 将标题转换为链接不会';t在灯箱2.51中工作,hyperlink,lightbox,caption,Hyperlink,Lightbox,Caption,在从下载的Lightbox 2.51中,将标题转换为链接不起作用 代码如下: <a href="images/examples/image-1.jpg" rel="lightbox" title="<a target='_self' href='http://www.google.com'>Google</a>"> <img src="images/examples/thumb-1.jpg" alt="" /&g
代码如下:
<a href="images/examples/image-1.jpg" rel="lightbox"
title="<a target='_self' href='http://www.google.com'>Google</a>">
<img src="images/examples/thumb-1.jpg" alt="" />
</a>
我该怎么办?谢谢:)尝试在标签中使用javascript onClick=“window.location.href=”http://www.google.com"" 样品
<a href="images/examples/image-1.jpg" rel="lightbox"
title="<a target='_self' onClick="window.location.href='http://www.google.com'" href='http://www.google.com'>Google</a>">
<img src="images/examples/thumb-1.jpg" alt="" />
</a>
我在
lightbox.js
中找到了这个问题的解决方案。
您必须编辑if
案例,添加else
条件,以避免在单击div
“lightbox”时始终返回false
我一直无法在这里找到任何对我有用的答案。但是,我发现它确实有效,而且交换非常简单,因为它使用相同的语法。我发现我认为比上面使用Lightbox 2 2.6版的解决方案更好。在lightbox.js(unnified)的第252行,您将看到这一行添加了标题:
this.$lightbox.find('.lb-caption').html(this.album[this.currentImageIndex].title).fadeIn('fast');
添加标题后,您可以注册单击事件,并通过如下方式添加到链中,强制浏览器跟随标题中的任何链接:
this.$lightbox.find('.lb-caption').html(this.album[this.currentImageIndex].title).fadeIn('fast').find('a').on('click', function() { location.href = $(this).attr('href') });
我已经启动了一个与此更改相关的应用程序,以便您可以跟踪状态和任何进一步的讨论。此方法可能在大多数情况下都有效,但我认为它可能会产生一些无意的副作用,因为它会影响到所有到灯箱的点击。我在下面的回答中添加了一个更有限的干预,它只会在标题内的链接上注册一个事件。
this.$lightbox.find('.lb-caption').html(this.album[this.currentImageIndex].title).fadeIn('fast').find('a').on('click', function() { location.href = $(this).attr('href') });