Advertisement
pusatdata

JS: Today Date in Image url and Link url

Mar 13th, 2015
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. <html>
  2. <head>
  3.  
  4. <script>
  5. //<![CDATA[
  6. window.onload=function(){
  7.  
  8. Date.prototype.toMyString = function () {
  9. //If month/day is single digit value add perfix as 0
  10. function AddZero(obj) {
  11. obj = obj + '';
  12. if (obj.length == 1)
  13. obj = "0" + obj
  14. return obj;
  15. }
  16.  
  17. var output = "";
  18. output += this.getFullYear();
  19. output += AddZero(this.getMonth()+1);
  20. output += AddZero(this.getDate());
  21.  
  22. return output;
  23. }
  24.  
  25. var d = new Date();
  26.  
  27. var link = document.getElementById("image");
  28. link.setAttribute("src","http://cache3-img1.pressdisplay.com/pressdisplay/docserver/getimage.aspx?file=6107"+d.toMyString()+"00000000001001&page=1&scale=44");
  29.  
  30.  
  31. var link = document.getElementById("link");
  32. link.setAttribute("href","http://www.pressdisplay.com/pressdisplay/pageview.aspx?issue=6107"+d.toMyString()+"00000000001001");
  33.  
  34.  
  35. }//]]>
  36. </script>
  37.  
  38. </head>
  39.  
  40. <body>
  41. <center>
  42. <img id="image" width="200"><br/>
  43. <a id="link" href="#">Read Today Epaper</a>
  44. </center>
  45. </body>
  46. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement