Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

make url clickable js


//////// posted by Programmer Rimon\\\
// Date: 07-02-2022 *D-M-Y*
function makeUrlsClickable(s) {
	if(!s) return '';
	// make URLs clickable
	s = s.replace(/(^|s|>)(www.([w#$%&~/.-+;:=,?[]@]+?))(,|.|:|)?(?=s|&quot;|&lt;|&gt;|"|<|>|$)/gi, '$1<a href="http://$2" target="_blank">$2</a>$4');
	return s.replace(/(^|s|>)((?:http|https|ftp)://([w#$%&~/.-+;:=,?[]@]+?))(,|.|:|)?(?=s|&quot;|&lt;|&gt;|"|<|>|$)/ig, '$1<a href="$2" target="_blank">$2</a>$4');
};
 
PREVIOUS NEXT
Tagged: #url #clickable #js
ADD COMMENT
Topic
Name
8+9 =