Search
 
SCRIPT & CODE EXAMPLE
 

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');
};
Comment

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');
};
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript context arc set color 
Javascript :: js nearest 100 
Javascript :: dummy json 
Javascript :: jquery :not class 
Javascript :: load js file 
Javascript :: jquery serialize form to json 
Javascript :: Remove all child nodes of a list: 
Javascript :: javascript onclick display none 
Javascript :: add option to select jquery 
Javascript :: remove extra spaces javascript 
Javascript :: jquery select option value id no not exists 
Javascript :: using .indexOf() in jShell 
Javascript :: npm windows shocut 
Javascript :: angular remove item from localstorage 
Javascript :: javascript test if element has focus 
Javascript :: YT.Player is not a constructor 
Javascript :: find the missing value in an integer array javascript 
Javascript :: nodejs chaning env variable at runtime 
Javascript :: gmail regex 
Javascript :: get all input values by class jquery 
Javascript :: Firebase CLI v11.0.1 is incompatible with Node.js v14.17.6 Please upgrade Node.js to version = 14.18.0 
Javascript :: js remove specific css property 
Javascript :: js json upload 
Javascript :: how to get sys time in js 
Javascript :: upsert mongoose 
Javascript :: convert string to datetime javascript 
Javascript :: fibonacci recursion javascript 
Javascript :: moment hour minute 
Javascript :: js html play beep 
Javascript :: jquery get element by id from variable 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =