Answers for "javascript replace url with links"

0

javascript url replace

function URLReplacer(str){
        let match = str.match(/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig);
        let final=str;
        match.map(url=>{
            final=final.replace(url,"<a href=\""+url+"\" target=\"_BLANK\">"+url+"</a>")
        })
        return final;
      }
Posted by: Guest on October-26-2020
-1

change url link javascript

element.setAttribute('href','http://www.google.com');
Posted by: Guest on June-28-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language