Advertisement
pusatdata

JS: Menambahkan Tanggal Hari Ini pada IMAGE URL

Jan 4th, 2015
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 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("link");
  28.  
  29. link.setAttribute("src","http://cache3-img1.pressdisplay.com/pressdisplay/docserver/getimage.aspx?file=6107"+d.toMyString()+"00000000001001&page=1&scale=44");
  30.  
  31. }//]]>
  32. </script>
  33.  
  34. </head>
  35.  
  36. <body>
  37. <img id="link" width="100">
  38. </body>
  39. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement