Answers for "how to replace url in javascript"

3

js change url

window.location.href = "www.google.com";
Posted by: Guest on May-07-2020
3

javascript change url

var url =  window.location.origin + '/foo/foo.php';
history.pushState({}, null, url);
Posted by: Guest on June-15-2021
3

javascript change url

history.pushState({}, null, newUrl);
Posted by: Guest on March-20-2020
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

Code answers related to "how to replace url in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language