PDA

View Full Version : last modified challenge!!


kevin_huinink
05-19-2003, 04:27 PM
I want an HTML document to
dynamically post the 'last modified' date of another document on the
Internet.
eg. I upload our newsletter.pdf
The News page with a link to the pdf should read
"This file last updated/uploaded on ___________"

Possible?

brothercake
05-19-2003, 04:59 PM
Please read the posting guidelines - http://www.codingforums.com/postguide.htm - specifically the bit about choosing an appropriate title. Baiting for answers by dressing up your question as a "challenge" usually has the opposite effect from what you intended.

brothercake
05-19-2003, 08:32 PM
As to your question - no, you can't read the last modified date of an external document with javascript. But a server side language could do it.

jalarie
05-22-2003, 02:56 PM
Well, brothercake, yes and no. If the target file is on another domain, you're right. And if it's any type of file not normally displayed by a browser, you're right. But:

 PopUp1=window.open('target.htm','x');
 LM=PopUp1.document.lastModified;
 alert(LM);
 PopUp1.window.close();

jalarie
05-22-2003, 03:27 PM
Never being one to leave well-enough alone, I had to expand upon the above:

 function GetLM() {
   Targets=new Array(
     'target1.htm',
     'target2.htm',
     'target3.htm',
     'target4.htm'
   );
   PopUp1='';
   Message='';
   ix1=-1;
   AddLM();
 }
 function AddLM() {
   if ((PopUp1) && (!PopUp1.closed)) { PopUp1.window.close(); }
   ix1=ix1*1+1*1;
&nbsp;&nbsp;&nbsp;if&nbsp;(ix1*1&nbsp;<&nbsp;Targets.length)&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Target=Targets[ix1];
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Opts='width=100,height=100';
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PopUp1=window.open(Target,'x',Opts);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.window.focus();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LM=Target+':&nbsp;'+PopUp1.document.lastModified;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Message+='\n'+LM;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TimeOut1=setTimeout("AddLM()",500);
&nbsp;&nbsp;&nbsp;}&nbsp;else&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert(Message);
&nbsp;&nbsp;&nbsp;}
&nbsp;}