title: Redirect url link based on login user using javascript
body: <p>How to create url link based on user name(gmail). 
  Eg: <a href="http://www.test.com/%username%" rel="nofollow">http://www.test.com/%username%</a></p>
  
  <p>The following code more or less suitable for me. Only i want to know how to get username automatically on the input area.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      function changeText(){
          var userInput = document.getElementById('userInput').value;
          var lnk = document.getElementById('lnk');
          lnk.href = "http://www.test.com" + userInput;
          lnk.innerHTML = lnk.href;
      }
      &lt;/script&gt;
      Link : &lt;a href="" id=lnk&gt;nothing here yet&lt;/a&gt; &lt;br&gt;
      &lt;input type='text' id='userInput' value='Enter username' /&gt;
      &lt;input type='button' onclick='changeText()' value='Change Link'/&gt;
  </code></pre>
  
  <p>Here also same issue</p>
  
  <pre><code>&lt;a id="reflectedlink" href="http://www.google.com/search"&gt;http://www.test.com/&lt;/a&gt;
  &lt;input id="username"/&gt;
  
  &lt;script type="text/javascript"&gt;
      var link= document.getElementById('reflectedlink');
      var input= document.getElementById('username');
      input.onchange=input.onkeyup= function() {
          link.search= '/'+encodeURIComponent(input.value);
          link.firstChild.data= link.href;
      };
  &lt;/script&gt;
  </code></pre>