Add datetime inside a html url - Javascript DOM

Javascript examples for DOM:Element setAttribute

Description

Add datetime inside a html url

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <script type="text/javascript">
function addtimestamp() {// w  ww. j a v a 2s . co  m
    var link = document.getElementById('link');
    var now = new Date().getTime();;
    link.setAttribute("href", "/controllername?t=" + now);
}

      </script> 
      <a id="link" onclick="addtimestamp()" href="/controllername?t=">url</a>  
   </body>
</html>

Related Tutorials