Javascript examples for String Operation:String URL
URL with domain substitution
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/*from ww w . j ava2s .c o m*/ function makeLink(lang) { return document.location.href.replace(document.location.hostname, lang + "." + document.location.hostname) } console.log(makeLink("fr")); } </script> </head> <body> </body> </html>