js基础:JavaScript 小技巧之如何自动加上最后修改时间


我们在 HTML 文件档完成了以后,常会加上一行文件最后修改的日期。现在你可不用担心每次都要去改或是忘了改了,你可以很简单的写一个如下的描述语法程式。就可以自动的为你每次产生最后修改的日期了。

  <html>
  <body>
  This is a simple HTML- page.
  <br>
  Last changes:
  <script language="LiveScript">
  <!-- hide script from old browsers
  document.write(document.lastModified)
  // end hiding contents -->
  </script>
  </body>
  </html>

  以上的 document.lastModified 参数在 Netscape 2.0beta 2 版时是被写成documeut.lastmodified 的。然而之后的版本就改为 document.lastModified。所以注意一下JavaScript 本身是会区分大小写的  lastmodified 与lastModified在它看来是不同的结果。


« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3