Turning a title into a link does not work in Lightbox 2.51

Turning the title into a link does not work in Lightbox 2.51, downloaded from here
Here is the code:

<a href="images/examples/image-1.jpg" rel="lightbox" title="&lt;a target='_self' href='http://www.google.com'&gt;Google&lt;/a&gt;"> <img src="images/examples/thumb-1.jpg" alt="" /> </a> 

What should I do?
Thanks:)

+6
source share
4 answers

I found a solution to this problem in lightbox.js . You must edit the if case by adding an else condition that will always return false when you press the div button. "

  $lightbox.hide().on('click', function(e) { if ($(e.target).attr('id') === 'lightbox') { _this.end(); return false; } else { // HERE return true; } }); 
+11
source

I found what I consider to be a better solution than the ones listed above using Lightbox 2 version 2.6. On line 252 lightbox.js (unminified) you will see this line that will add a signature:

 this.$lightbox.find('.lb-caption').html(this.album[this.currentImageIndex].title).fadeIn('fast'); 

After adding a caption, you can register a click event and force the browser to follow any link in the header, adding to the chain like this:

 this.$lightbox.find('.lb-caption').html(this.album[this.currentImageIndex].title).fadeIn('fast').find('a').on('click', function() { location.href = $(this).attr('href') }); 

I initiated a pull request with this change so that you can keep track of the status and any further discussions there.

+3
source

Try using javascript in the tag

onClick = "window.location.href = 'http: //www.google.com'"

Example

  <a href="images/examples/image-1.jpg" rel="lightbox" title="&lt;a target='_self' onClick=&quot;window.location.href=&#x27;http://www.google.com&#x27;&quot; href='http://www.google.com'&gt;Google&lt;/a&gt;"> <img src="images/examples/thumb-1.jpg" alt="" /> </a> 
+1
source

I could not get all the answers to work for me. However, I found that Slimbox2 works and is very easy to swap since it uses the same syntax.

0
source

Source: https://habr.com/ru/post/918560/


All Articles