Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

made clickable url in js

/*****Make Urls clickable in JS*****/
function prepareHtml(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: #clickable #url #js
ADD COMMENT
Topic
Name
6+2 =