Hi,
Is it possible to display the last modified date/time as a comment in HTML?
<script>
document.write(document.lastModified);
</script>
Thanks!
Hi,
Is it possible to display the last modified date/time as a comment in HTML?
<script>
document.write(document.lastModified);
</script>
Thanks!
What do you mean by “comment”?
<!-- Do you mean this? -->
I’m sure you could… I don’t see what the point would be though. Javascript is only run clientside and if the client can’t see it, then why do it?
Yes, I mean like that.
It would be useful for my team to see when the page was last updated by just viewing the source.
Ah. Seems odd… but here you go:
<script>
window.onload = function() {
document.body.innerHTML += '<!-- ' + document.lastModified + ' -->';
}
</script>
I’ve never used the document.lastModified method before. The info on it is sparse… make sure it does what you want it to do. Seems like a very weird thing to be on the client-side.
I tried something similar to this, hoping to help with this question, but document.lastModified changed every time I loaded the page, always reflecting the current time.
I’m trying to figure out an AJaX way of doing it, but I’m not using IIS or Apache as a webserver (I’m running ColdFusion Servers built-in web server.)
http://help.adobe.com/livedocs/coldfusion/8/htmldocs/help.html?content=functions_e-g_39.html
<cfscript>
WriteOutput(GetFileInfo("c:\ emp\ est1.txt").lastmodified);
</cfscript>
!
Thanks for the CF method. That will come in handy, I’m sure, in the future.
But I’m thinking of switching from CFs built-in Tomcat webserver to Apache (to reflect production environment). So there might be an AJaX way of getting “Last-Modified” response header.
Most hosting providers now block access the file dates so lastModified will almost always return the date and time it is run.
Bummer. So even if I did find/write a script to do so, it’s already thwarted by most ISPs.:smash: