Equipping You to Communicate Effectively
| support CMN & share a |
library of 19K+ images, videos, etc
| ||Thread Tools||Search this Thread||Rate Thread||Display Modes|
Java "document.lastModified" not working???
This is wierd...
I am using the following code snippet to show when a webpage was last updated..
Instead of showing when it was last modified, it shows the current date/time!
I recently moved to a Godaddy shared host and added google analytics code. Before that, the code below worked fine.
Anyone have any suggestions?
Here is the website:
var m = "Page last updated " + document.lastModified; var p = m.length-0; //can remove time by changing 0 to 8 document.write(m.substring(p, 0));
If it worked before you moved to your new host, then you may want to contact them about it.
Without being able to see your setup and play with the server, I would think that it has to do with how the server actually feeds out your pages. (ie. takes your page and parses it out, so it is actually dynamically created, thus making a timestamp of whenever you call it.
Your hose should be able to advise you more.
Well it turns out that the issue is that the server is not including the lastmodified information in the HTTP header.
See this for an explanation: http://www.quirksmode.org/js/lastmod.html
I will try to work with Godaddy on this, but I doubt they are going to budge as this is a shared hosting account.
Any other suggestions on how I could accomplish the same thing?
You can only safely accomplish this using a server-side solution, such as PHP, ASP, Server Side Includes, or any number of similar options. In PHP, this would look like:
$modified = filemtime("filename");
echo "Modified on " . date("F dS Y - h:ia", $modified);
http://kanago.net - experiences in media