zoukankan      html  css  js  c++  java
  • 关于document.lastModified属性

    在javascript中,document有一个lastModified属性,是记录了页面的最后更新时间。但这个最后更新时间究竟是物理网页 文件的最后修改时间,还是dom树的最后更新时间呢?lastModified作为document的一个属性很容易让人联想到后者,但事实是否是如此 呢?答案是否定的。

         我们编写如下测试代码:

     <html>
      <head>
      <script type="text/javascript">

                 function addElement(){
                     var body;
                     var newElement;
                          newElement = document.createElement('input');
                          newElement.setAttribute('type','text');
                          newElement.setAttribute('value','added element');
                          body = document.body;
                          body.appendChild(newElement);
                   }
              function showLastModified(){
                       alert(document.lastModified);
              }
             //function aa(){ }
    </script>
    </head>
    <body>
     <input id="btn1" type="button" value="test" />
     <div id="div1" style="450px;height:450px;display:block">display</div>
     <input type="button" value="添加元素" onclick="addElement();"/>
     <input type="button" value="document最后修改时间" onclick="showLastModified();"/>
    </body>
    </html>

    点击【添加元素】按钮向文档中添加新的元素或刷新页面,再点击【document最后修改时间】按钮查看网页最后修改时间,时间是不变的。而修改网页文件(添加一个空函数function aa后保存)最后修改时间发生改变。

         结论:document.lastModified记录的是物理网页的最后修改时间。

  • 相关阅读:
    linux发行版 以及 包管理方式
    [Linux: 使用心得]ArchLinux下安装Gnome3
    Delphi中WebService服务
    再谈企业架构业务架构
    SQL优化使用 EXISTS 代替 IN 和 inner join来选择正确的执行计划
    数据库设计使用上述四种模式的一般原则(转)
    SQL server 2005 日志恢复和审计工具
    Oracle 10g 进程体系学习总结
    查看SQL Server的事务日志
    数据库设计继承模式(转)
  • 原文地址:https://www.cnblogs.com/webqiand/p/4609390.html
Copyright © 2011-2022 走看看