Forum Moderators: open

Message Too Old, No Replies

Need to add lastmodified for pages on website

document.lastModified

         

Alina

6:25 pm on Nov 5, 2008 (gmt 0)

10+ Year Member



I have added added the script
<script language="JavaScript">
<!--
document.write("Page last modified " + document.lastModified)
// -->
</script>
to my website *.htm pages but when I view a page in the brower (IE7) I am seeing todays date and time instead of the actual date and time that the page was actually modified. Please help?

Trace

9:21 pm on Nov 5, 2008 (gmt 0)

10+ Year Member



I haven't seen that used in a very long time, but it seem to look correct.

You know that adding that script to your page is in itself modifying the page. Close the page, wait a little while, and see if the date/time changes.

daveVk

12:38 am on Nov 6, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Your server is probably not sending a Last-Modified: header ( or an incorrect one ) check the server headers

jalarie

6:46 pm on Dec 1, 2008 (gmt 0)

10+ Year Member



The document.lastModified item is in a group where some of the items can be used to attack the server. To protect against this, some server operators forbid the entire group rather than working hard to block only the offensive items. The server then sends a null response for all items in the group.

IE uses the null as-is in the Date() function and gets the current date and time. This makes it appear that you updated the page within the last few seconds; great if you want to impress your visitor; bad if you want to be accurate about what is going on.

Netscape forces the null to be numeric, gets a zero at that point, and uses the zero in the Date() function. The result is always "January 1, 1970, GMT" and then gets adjusted for your timezone offset. For me in the eastern USA, the printed value is "December 31, 1969, 7:00pm."

WebTV (which I haven't seen in quite a while, but I happen to know its action) also forces the null to be numeric, but adjusts for timezone before going to the Date() function. The result for visitors west of London is a negative value and a crash of the code.

All other browsers that I've checked give one of the three results listed above.

[edited by: tedster at 9:47 pm (utc) on Dec. 2, 2008]