clickable links in item description
eliz82
Joined: 2009-11-06
Posts: 71 |
![]() |
any idea how to make links clickable in the description of an item? |
|
suprsidr
![]()
Joined: 2005-04-17
Posts: 8339 |
![]() |
eliz82
Joined: 2009-11-06
Posts: 71 |
![]() |
i allready read that thread and other similar (http://gallery.menalto.com/node/95000) have you test this solution ? |
|
suprsidr
![]()
Joined: 2005-04-17
Posts: 8339 |
![]() |
assuming the description field has a class of "giDescription" <script type="text/javascript"> $(document).ready(function() { var h = $('.giDescription').html(); if(h) $('.giDescription').html(h.replace(/((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi, '<a href="$1" target="_blank">$1</a>')); }); </script> vanilla javascript: <script type="text/javascript"> window.onload = function() { var e = document.querySelector('.giDescription'); var h = e.innerHTML; if(h) e.innerHTML = h.replace(/((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi, '<a href="$1" target="_blank">$1</a>'); }; </script> @see it working here. -s |
|
eliz82
Joined: 2009-11-06
Posts: 71 |
![]() |
the class of my description is giDescription under {literal} <script type="text/javascript" scr="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { var h = $('.giDescription').html(); if(h) $('.giDescription').html(h.replace(/((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi, '<a href="$1" target="_blank">$1</a>')); }); </script> {/literal} then i cleared the cache of gallery and my browser. but it dosent seem to work i have also tried vanilla javascript (pure javascript?). the same problem, the code is there just under <body>, but not working. what i'm doing wrong ? |
|
suprsidr
![]()
Joined: 2005-04-17
Posts: 8339 |
![]() |
jquery is not being loaded use: -s |
|
eliz82
Joined: 2009-11-06
Posts: 71 |
![]() |
i had a look and the source of generated and was perfect for me. i have modified and try the pure javascript {literal} <script type="text/javascript"> window.onload = function() { var e = document.querySelector('.giDescription'); var h = e.innerHTML; if(h) e.innerHTML = h.replace(/((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi, '<a href="$1" target="_blank">$1</a>'); }; </script> {/literal} i see the code correct in the source, but it's not working. i have also tried this code on a html test page and it works perfect. |
|
suprsidr
![]()
Joined: 2005-04-17
Posts: 8339 |
![]() |
previously you had a2 js errors on that page: AND -s |
|
suprsidr
![]()
Joined: 2005-04-17
Posts: 8339 |
![]() |
Oh and BTW -s |
|
eliz82
Joined: 2009-11-06
Posts: 71 |
![]() |
i have save a html file of that page using browser save as. then i started to delete portions of the html code and refresh the page. {if isset($ImageBlockData.show.title) && isset($block.item.title)} <h4 class="giDescription"> {$block.item.title|markup} </h4> {/if} i have replaced the giDescription with something else and your javascript is working. suprsidr wrote:
src= not scr= p.s. do you use a browser plugin to see javascript errors on a page ? |
|
suprsidr
![]()
Joined: 2005-04-17
Posts: 8339 |
![]() |
Quote:
p.s. do you use a browser plugin to see javascript errors on a page ? I prefer firbug but built-in browser tools are getting better. -s |
|
suprsidr
![]()
Joined: 2005-04-17
Posts: 8339 |
![]() |
you need to make sure there is a space after the link. like your example page shows the link http://google.com</span></li> which would not resolve. -s |
|
eliz82
Joined: 2009-11-06
Posts: 71 |
![]() |
yes, i have replaced with |
|