Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js convert urls in content to links

function convert(text)
{
  var exp = /((https?|ftp|file)://[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|])/ig;
  var text1=text.replace(exp, "<a href='$1'>$1</a>");
  var exp2 =/(^|[^/])(www.[S]+(|$))/gim;
  return text1.replace(exp2, '$1<a target="_blank" href="http://$2">$2</a>');
}
Source by talkerscode.com #
 
PREVIOUS NEXT
Tagged: #js #convert #urls #content #links
ADD COMMENT
Topic
Name
7+9 =