URL with domain substitution - Javascript String Operation

Javascript examples for String Operation:String URL

Description

URL with domain substitution

Demo Code

ResultView the demo in separate window

<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>

Related Tutorials