faqts : Computers : Programming : Languages : JavaScript : Images

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

23 of 29 people (79%) answered Yes
Recently 6 of 10 people (60%) answered Yes

Entry

How do I get the last modified date of an IMG element?

Aug 6th, 2002 14:21
David Blackledge, Martin Honnen,


IE4/5 make that data available as
  imgElement.fileModifiedDate
so
  <IMG SRC="kiboInside.gif" ONCLICK="alert(this.fileModifiedDate);">
shows the last modified date for the IMG.
NN2/3/4 don't make that data available to js. But you can use the code 
of
http://www.faqts.com/knowledge-base/view.phtml/aid/943/fid/189/lang/
to access the last modified date of a url with NN4 by calling into java. 
Of course such a url could be one of an IMG element.
----------------
Another option in N4 is to open the Image in its own window or frame, 
then getting the "document"'s lastModified date which is the 
lastModified date of the Image:
var x=window.open("http://www.faqts.com/images/javascript-faqts.gif");
setTimeout("alert(x.document.lastModified)",100);
The setTimeout is necessary to give the Image time to load.  100 should 
be enough if you've preloaded the image into cache, or if you have a 
high-speed connection.
http://David.Blackledge.com