网页“时间戳”

时间:2010-10-27 18:41:28

标签: web

是否有可以验证您网页的网站。具体来说,假设您在星期一创建了一个网页,并希望您的用户在星期二查看同一页面时确信它与Mondya上发布的页面相同(未经任何修改)。

谢谢。

2 个答案:

答案 0 :(得分:1)

要获取网页的上次修改数据,您可以将document.lastModified属性与javascript一起使用。

为了确保您的用户,请参阅:

答案 1 :(得分:0)

您可以使用一点点javascript来验证自己的网页

<script type="text/javascript" language="JavaScript" src="lastupdated.js"></script>
<script type="text/javascript" language="JavaScript">
<!-- Write last modified date at the bottom of the page
var dateObj = new Date(document.lastModified)
var dateString = lastUpdated(dateObj)
document.write(dateString)
// -->
</script>

这是最后更新的JavaScript

function lastUpdated(dateObj)
{
var dayNames = new Array(8);
dayNames[1] = "Sunday";
dayNames[2] = "Monday";
dayNames[3] = "Tuesday";
dayNames[4] = "Wednesday";
dayNames[5] = "Thursday";
dayNames[6] = "Friday";
dayNames[7] = "Saturday";

var monthNames = new Array(13);
monthNames[1] = "January";
monthNames[2] = "February";
monthNames[3] = "March";
monthNames[4] = "April";
monthNames[5] = "May";
monthNames[6] = "June";
monthNames[7] = "July";  
monthNames[8] = "August";
monthNames[9] = "September";
monthNames[10] = "October";
monthNames[11] = "November";
monthNames[12] = "December";

var theDay = dayNames[dateObj.getDay() + 1];
var theMonth = monthNames[dateObj.getMonth() + 1];
var dayNumber = dateObj.getDate();
var fullYear = dateObj.getYear();
if (fullYear < 1900) { fullYear = fullYear + 1900 };
var dateString = '<center><font face="arial, helvetica" size="-3">' + "Last modified on " + theDay + ", " + theMonth + " " +         dayNumber + ", " + fullYear + " </font></center>";
return dateString;
}