Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Modified Date to work when javascript off

Status
Not open for further replies.

robert89

Technical User
Nov 19, 2003
125
CA
Does anyone know of a way to have the modified date showup when javascript is turned off?

Thanks,
Bob
 
Sorry! The modified date would be the last date that a web page (html 4.01) was modified. Until now we have been changing the date manually. Would prefer to have it automatic and have script that does so. However, when page is live and javascript is turned off in browser, date disappears.

Thanks

 
Are you looking for this?
Code:
document.write("The page that contains this example was last updated on: "+document.lastModified+"")
 
Hi mrplow,
I have a variation of the above, but what I am looking for is a way of having the date update when modified, but not disappear if a visitor has their javascript turned off.

Thanks,
Bob
 
I'm not sure there is a way to do that. I guess just ask them nicely to turn their javascript on?
 
Hi mrplow,
Thought that might be the case, but was hopin' ...

Bob
 
Hi BillyRay,
Not being technically savy. Is server side code not what you get when you place a document.write statement in your code.

Or is server side code something that the visitor has no control over. If it is, would be interested in a bit more info on what I should be looking for.

The problem we are trying to solve is accessibility priority "#??" where the information must appear if the visitor has turned off javascript, or whatever.

Thanks,
Bob
 
Server-side code, as the name implies, is code run on the server. It is not, like client-side Javascript, run on the client (i.e. browser).

This means it is perfect for what you want (WRT accessibility, etc).

Server-side code can be written in a number of languages, including VBScript and Javascript (.asp), Cold Fusion (.cfm), Java (.jsp), PHP (.php), and many more.

You should speak to your techy bods to find out if your host supports these, and then ask in the most suitable forum about how to get the last modified date of a document.

Hope this helps,
Dan


[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Hi BillyRay,
Well, that was the direction I was looking for.
Thanks,
Bob
 
Here is a sample usin ASP

<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>

<form name="attributes" Action="">

<%

dim dateModified

dateModified = FileDateTime( server.mappath(lcase(request.servervariables("SCRIPT_NAME"))) )
%>

<%=tmpFileName%><br>
Date Last Modified&nbsp;&nbsp;<%=dateModified%><br>

</form>
</HTML>

<%
Private Function FileDateTime(byVal pathname)
Dim objFSO, objFile
On Error Resume Next
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(pathname)
If Err Then
FileDateTime = Null
Else
FileDateTime = CDate( objFile.DateLastModified )
End If
Set objFile = Nothing
Set objFSO = Nothing
On Error GoTo 0
End Function
%>
 
Hi 4345487 (Programmer),
Thank you very much. Is the idea to just add this script to my html page and my date is off and running?

Thanks again,
Bob
 
You can also just use the server-side include for the last modified date. Doesn't require any programming at all.
Code:
<!--#echo var="LAST_MODIFIED" -->

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
hi tsdragon,
I placed the code you provided in my html page. Nothing appears when I view it in a browser. Is there something I should be adding/removing etc. Does the page need to be saved as asp? Is this asp script, php or something else?

Thanks,
Bob
 
You can't just place the code in a page and hope it works. You have to ensure that:

1. Your web server supports ASP, and
2. Your web server is parsing the file you've edited server-side. This is normally decided based upon the file extension (usually .ASP, .JSP, .PHP, etc, depending on what technology you use).

Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
To amend what BRPS said, if you are using the server-side include then you need to ensure that:

1. Your web server supports server-side includes (SSI), and
2. You may have to use the extension .shtml to make it work.


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Thanks all,
Got home last night, where I have greater flexiblity for trial and error and did a couple of includes. Wow! Cool!

Bob
 
There are other things you can do with server-side includes too. Here are links to a couple of tutorials/references (just do a google search for "server side include" to find more):





Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top