/    Sign up×
Community /Pin to ProfileBookmark

date & time stamp for links /linked files

Hi,

I’d like to add automatically a date & time stamp to a webpage below links to files (.pdf, .xls, .html) on the local file server. The date & time should represent the file-save date & time.

Sample.xls
Updated Sep.24 2004 6:49 PM

Thank you for your help.

Stefan
p.s
Is it somehow possible to detect in which time zone …6:49… the save took place?¿

to post a comment
JavaScript

22 Comments(s)

Copy linkTweet thisAlerts:
@CharlesSep 25.2004 — It's easily done, but you cannot do it with JavaScript. You'll need some sort of serer side scripting. Or, you could write a little utility that edits your links page as it uploads your file.
Copy linkTweet thisAlerts:
@StefanSparksauthorSep 26.2004 — both sound greek to me. what is the easier approach?

The page i'd like to add this functionality to is on our local network?. To do a serverside scripting, does it matter where the page is located or what software is running on the server? (Would it matter if there are two networks with different software?)

I'm sure you have better things to do then fixing MY problem. I'd really appreciate your help.

Stefan

p.s.

A week ago or so i found this somewhere, and can not find it again nor can i remember where i got this from. This is supposed to add a time/date stamp.... i couldnt figure out how to apply this... Is this what you referred to?

<%=Response.Write%>

<%Dim objFSO, objFile

Set objFSO = _

Server.CreateObject("Scripting.FileSystemObject")

Set objFile = objFSO.GetFile(Server.MapPath("folder/file"))

Dim dtModified

dtModified = objFile.DateLastModified

Set objFile = Nothing

Set objFSO = Nothing

Response.Write(dtModified)

%>
Copy linkTweet thisAlerts:
@Warren86Sep 26.2004 — Stefan:

You could try something like the following. You'll have to specify the path info in the VBS section.

<HTML>

<Head>

<Script Language=JavaScript>

var lastAccess = "";

function getLink(isLink,linkName){

updateInfo(isLink)
document.getElementById(linkName).innerText = lastAccess;
window.open(isLink);
}


</Script>

<Script Language=VBScript RunAt=Server>

isPath = "C:SomeFolderSomeOtherFolder"

function updateInfo(fileSpec)

Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set contentFile = fso.GetFile(Server.MapPath(isPath+fileSpec))
strInfo = "Last Accessed: "
strInfo = strInfo & contentFile.DateLastAccessed
strInfo = strInfo & " Last Modified: "
strInfo = strInfo & contentFile.DateLastModified
lastAccess = strInfo
Set contentFile = Nothing
Set fso = Nothing

End Function


</Script>

</Head>

<Body>

<center>

<a href=javascript:getLink('Sample1.html','link_name1')> Sample Link 1 </a>

<Div id='link_name1'></Div>

<br><br>

<a href=javascript:getLink('Sample2.html','link_name2')> Sample Link 2 </a>

<Div id='link_name2'></Div>

<br><br>

<a href=javascript:getLink('Sample3.html','link_name3')> Sample Link 3 </a>

<Div id='link_name3'></Div>

</center>

</Body>

</HTML>
Copy linkTweet thisAlerts:
@StefanSparksauthorSep 27.2004 — Hi Warren,

Thank you for your help.

I used the code you provided and modified it as to how I understood your advise(specify the path info in the VBS section) and changed only the part (isPath = "C:SomeFolderSomeOtherFolder").Unfortunately, unsuccessful.

I even created the folder structure and the three files (sample1, 2 and 3 .html). Unfortunately, did not work either.

I'm quite confident that the error is on my part and would appreciate your patience to point out where I went wrong to get this to work.

Thank you.

Stefan
Copy linkTweet thisAlerts:
@Warren86Sep 27.2004 — Stefan:

Are you testing it locally, or did you upload it to your site? If there is an error notice in the bottom left corner, the little yellow exclamation point, double click it and tell me what the error is. You might first try just eliminating the the RunAt=Server statement. And, could you tell me exactly what did you change the isPath to?

Also, here's s version you can test locally. It's what I used, and it worked fine. If you can get it to work, maybe this will help

<HTML>

<Head>

<Script Language=JavaScript>

var lastAccess = "";

function getLink(isLink,linkName){

updateInfo(isLink)
document.getElementById(linkName).innerText = lastAccess;
window.open(isLink);
}


</Script>

<Script Language=VBScript>

isPath = "C:WindowsDesktopProjectTesting"

Function updateInfo(fileSpec)

Set fso = CreateObject("Scripting.FileSystemObject")
Set contentFile = fso.GetFile(isPath+fileSpec)
strInfo = "Last Accessed: "
strInfo = strInfo & contentFile.DateLastAccessed
strInfo = strInfo & " Last Modified: "
strInfo = strInfo & contentFile.DateLastModified
lastAccess = strInfo
Set contentFile = Nothing
Set fso = Nothing

End Function


</Script>

</Head>

<Body>

<center>

<a href=javascript:getLink('Sample1.html','link_name1')> Sample Link 1 </a>

<Div id='link_name1'></Div>

<br>

<a href=javascript:getLink('Sample2.html','link_name2')> Sample Link 2 </a>

<Div id='link_name2'></Div>

<br>

<a href=javascript:getLink('Sample3.html','link_name3')> Sample Link 3 </a>

<Div id='link_name3'></Div>

</center>

</Body>

</HTML>
Copy linkTweet thisAlerts:
@Warren86Sep 27.2004 — Stefan:

Also, you might try it this way. Sometimes a blank line is first used to set fso. It's my understanding that this isn't necessary, but no harm in trying it.

<HTML>

<Head>

<Script Language=JavaScript>

var lastAccess = "";

function getLink(isLink,linkName){

updateInfo(isLink)

document.getElementById(linkName).innerText = lastAccess;

window.open(isLink);

}

</Script>

<Script Language=VBScript RunAt=Server>

isPath = "C:SomeFolderSomeOtherFolder"

function updateInfo(fileSpec)

Set fso = _

Server.CreateObject("Scripting.FileSystemObject")

Set contentFile = fso.GetFile(Server.MapPath(isPath+fileSpec))

strInfo = "Last Accessed: "

strInfo = strInfo & contentFile.DateLastAccessed

strInfo = strInfo & " Last Modified: "

strInfo = strInfo & contentFile.DateLastModified

lastAccess = strInfo

Set contentFile = Nothing

Set fso = Nothing

End Function

</Script>

</Head>

<Body>

<center>

<a href=javascript:getLink('Sample1.html','link_name1')> Sample Link 1 </a>

<Div id='link_name1'></Div>

<br><br>

<a href=javascript:getLink('Sample2.html','link_name2')> Sample Link 2 </a>

<Div id='link_name2'></Div>

<br><br>

<a href=javascript:getLink('Sample3.html','link_name3')> Sample Link 3 </a>

<Div id='link_name3'></Div>

</center>

</Body>

</HTML>
Copy linkTweet thisAlerts:
@StefanSparksauthorSep 27.2004 — Hi Warren,

I was able to get the 2nd option (Set fso = CreateObject("Scripting.FileSystemObject") you provided to work. Hooray! My file is called timetest.html (in, now, "C:Test") and then I used the three sample files from your example to keep the testing simple. - I have some questions about this.

1.The time/date info only shows once the link is selected. Can the file date info show for all links once the page (timetest.html) is loaded? This would allow the user to see if there a recent change before loading the target page.

2.How could the text for the time/date info be manipulated to have small font, and/or italic?

At this point, I was not able to get the server side code to work. Like you said, there is an error (details later after I test to make sure I did not goof it off) on the page. I will be testing this further later on. - If I have the "not-server-side" one working, do I even have to worry about it? - Would it matter that I don’t "upload" my page to the internet but keep the site on one of our local file servers and just copy and past site info and files from C: to L: or O: drive? Would it matter if i call the drives by their network name (O: = spkfs01datapool) since they are mapped differently from computer to computer (some call it O: some have a different drive-letter)?

Thank you so much for your help and patience.

Stefan
Copy linkTweet thisAlerts:
@Warren86Sep 27.2004 — Stefan:

Oh, I'm glad you told me that you will only be using it locally. Just ignore the server side example code. As long as you got the local testing one to work, I'm happy if you're happy. I'll post an example of how to have the time stamp appear as soon as the page is loaded along with the code to change its font/appearance, etc., later today.

I understand what your requirements are now, and I'll get back to you later, okay?
Copy linkTweet thisAlerts:
@StefanSparksauthorSep 27.2004 — Hi Warren,

You are quick in reading these posts. I was just going to add a question and noticed that you got the prior one already.

I failed to ask you if there is a way to not have a ActiveX control pop-up box pop up asking the user for Yes/No input. - Is this something that can be activated/disabled in the web browser? - Anyway, no pop-up box would be nice.

Thank you so much.

Stefan
Copy linkTweet thisAlerts:
@Warren86Sep 27.2004 — Stefan:

Regarding the Active X box, I believe you will have to speak with your system administrator. Your current Windows security settings for Active X controls cause the box to appear. Anyway, try the following code. I tested with the three links on the page, but it should work for how ever many links you have on the page. I set the 'timestamp' text to appear in 9pt blue italics. If you need any other "styles" for that text, let me know.

<HTML>

<Head>

<Style>

.timeStamp {

Font-Size : 9pt;
Font-Style : Italic;
Color : Blue;

}

</Style>

<Script Language=JavaScript>

var lastAccess = "";

function getTimeStamps(){

nLinks = document.links.length;
for (i=0; i<nLinks; i++)
{
tmp = document.links[i].toString();
tmp = tmp.split("'");
thisLink = tmp[1];
linkName = tmp[3];
updateInfo(thisLink);
document.getElementById(linkName).innerText = lastAccess;
}
}

function getLink(isLink,linkName){

updateInfo(isLink)
document.getElementById(linkName).innerText = lastAccess;
window.open(isLink);
}

window.onload=getTimeStamps;


</Script>

<Script Language=VBScript>

isPath = "C:WindowsDesktopProject"

Function updateInfo(fileSpec)

Set fso = CreateObject("Scripting.FileSystemObject")
Set contentFile = fso.GetFile(isPath+fileSpec)
strInfo = "Last Accessed: "
strInfo = strInfo & contentFile.DateLastAccessed
strInfo = strInfo & " -- Last Modified: "
strInfo = strInfo & contentFile.DateLastModified
lastAccess = strInfo
Set contentFile = Nothing
Set fso = Nothing

End Function


</Script>

</Head>

<Body>

<center>

<a href=javascript:getLink('Sample1.html','link_name1')> Sample Link 1 </a>

<Div id='link_name1' class='timeStamp'></Div>

<br>

<a href=javascript:getLink('Sample2.html','link_name2')> Sample Link 2 </a>

<Div id='link_name2' class='timeStamp'></Div>

<br>

<a href=javascript:getLink('Sample3.html','link_name3')> Sample Link 3 </a>

<Div id='link_name3' class='timeStamp'></Div>

</center>

</Body>

</HTML>
Copy linkTweet thisAlerts:
@StefanSparksauthorSep 27.2004 — Hi Warren,

I copied and pasted the code (as earlier) and made the adjustment for the folder and received an error. When clicking on the error icon, it shows

Line 35

Char 1

Error File not found

Code 0

URL file//c:testtimetest.html

I am sorry, I dont know where to start count to find Line 35 to maybe figure this out myself.

Any idea?

Thank you.

Stefan
Copy linkTweet thisAlerts:
@Warren86Sep 27.2004 — Stefan:

I'm sorry, there was no need to check that error. It was with the version that was server-side. It's meant to be used when someone is accessing your web site as they would any other web site, not for local use. I'm sorry. I thought I said to just ignore all of that. You are only going to be using this locally on your LAN, so all of the Server.this and Server.that code is not needed. I'm sorry I was not clear about that. Use whatever path information makes it work. If it ain't broke...
Copy linkTweet thisAlerts:
@StefanSparksauthorSep 27.2004 — Hi Warren,

Please don’t shot me, as I was not clear. I apologize. The error I described is what I received when I used your adjusted code to change the font, size, and color and to show the links date/time when the site is loaded. -I noticed your comment to disregards the server side script altogether.- So, unfortunately...broke.

Thank you.

Stefan
Copy linkTweet thisAlerts:
@Warren86Sep 27.2004 — Stefan:

The code for showing the timestamp when the page is loaded works. Maybe you should get the code I posted to work, as is, before you start copying and pasting. I can't read your mind.

All I can suggest is that you put an alert in the the getTimeStamps function, to see what values are being used. Like this:

function getTimeStamps(){

nLinks = document.links.length;

for (i=0; i<nLinks; i++)

{

tmp = document.links[i].toString();

tmp = tmp.split("'");

thisLink = tmp[1];

alert(thisLink);

linkName = tmp[3];

alert(linkName);

updateInfo(thisLink);

document.getElementById(linkName).innerText = lastAccess;

}

}



Did you change the path, to what you used when it worked?



It has to be the reason why "File Not Found"



Other than this, I give up. You told me it works locally, when you click on a link, and I've done nothing to change that. Honestly, I'm only here to offer "help." And I believe I've done that.



I honestly have nothing more to offer to you.
Copy linkTweet thisAlerts:
@StefanSparksauthorSep 27.2004 — Hi Warren,

Thank you for your help and patience; this is really appreciated.

I found that your second code (the one that added color, font specifics) had the following lines/references as 'java scrip' whereas it should have been 'javascript' as one word. Once i found and corrected that, it works, just like you predicted. And it looks beautiful.

<<

<a href=java script:getLink('Sample1.html','link_name1')> Sample Link >>

Thank you so much.

Stefan
Copy linkTweet thisAlerts:
@Warren86Sep 27.2004 — Stefan:

Wow! I must repeat, WOW! I cannot understand how that could happen when all I did was paste the entire file into the response box here on this site. But you know, I have seen instances when this system, changes javascript to, java script. It's inexplicable. But, I am very glad you have it working now.


Good luck with your project. It's nice information to have about time sensitive links, and I never even thought about doing something like this.

I'm glad I could help.
Copy linkTweet thisAlerts:
@StefanSparksauthorSep 29.2004 — Hi Warren,

I have another question, hoping you can help with this too.

<<window.open(isLink);>>

How can i modify this in order to not open a new window, but to open the links in the same frame? The Frame is currently called "Frame7223".

With the old program i am working with, Adobe Page Mill [stop lauging!] ;-) it usually opens these links with TARGET="Frame7223".

I could not find an answer on how to direct the window.open to this frame.

Any suggestion?

Thank you.

Stefan
Copy linkTweet thisAlerts:
@Warren86Sep 29.2004 — Hi Stefan:

Try this instead of the window.open:

window.frames['Frame7223'].location = isLink;

Or if you do not want the back button to be used to return to previous content in the frame, use this:

window.frames['Frame7223'].location.replace(isLink);
Copy linkTweet thisAlerts:
@StefanSparksauthorSep 29.2004 — Hi Warren,

Thank you for your suggestions. Unfortunately, both do not work. When clicking on the links that used to open in a new window, the little error symbol appears. Error: 'window.frames.NewsRight' is null or not an object. code 0 (I renamed the frame to see if that makes a difference, which it did not). Could this have something to do as to how the program I am using is handling frames? Would it help if I upload the three files to look at?

Thank you.

Stefan
Copy linkTweet thisAlerts:
@Warren86Sep 29.2004 — Stefan:

It was early when I responded and I am probably in error.

Instead of window.frames, try document.frames['NewsRight'].location = isLink;

I thought the name of the frame was Frame7223?

In the brackets, put the name of the frame.
Copy linkTweet thisAlerts:
@StefanSparksauthorSep 29.2004 — Hi Warren,

<<I thought the name of the frame was Frame7223?>> Correct, I changed to name to see if that would make a difference. I changed the frame name in the brackets.

Unfortunately the <<document.....>> did not change the error message. It now just reads document instead of window.

Thank you.

Stefan
Copy linkTweet thisAlerts:
@Warren86Sep 29.2004 — Stefan, sent you a PM.
×

Success!

Help @StefanSparks spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...