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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Java script to show "last updated" date problem!

Status
Not open for further replies.

aboujouj83

IS-IT--Management
May 9, 2003
52
0
0
US
Hi,
I am trying to come up with a javascipt that tells me when I modify any page on my website...not just the index.htm
So I want the js to update the "last modified: " each time I make any change to any of the pages. I need some help, as I am not an expert in javascript.
Aboujouj
 
Usually you would achieve this using some of the server side include functionality in your web server (Apache springs to mind with this kind of functionality).

The only solution that is entirely Javascript would revolve around the use of the FileSystemObject in IE for Windows only. Hardly a complete solution.

Sorry,
Jeff
 
This method is slightly cumbersome and does mean you have to remember to edit one other file whenever you change any of the pages on your site. But it does work (I've used it!).

Firstly, create a file in your site called "[tt]lastmodified.js[/tt]", with one line:
Code:
   var dtLastModified = new Date("10 January 2003 17:10 GMT");
Now, change your page(s) as follows:
Code:
   <html>
     <head>
       ...
       <script type=&quot;text/javascript&quot; src=&quot;lastmodified.js&quot;></script>
       ...
     </head>
     <body>
        ...
        <p>Site last updated:
           <script>document.write(dtLastModified.toLocaleString());</script>
        </p>
     </body>
   </html>
This will deislay the modifcation date in the user's timezone: remember to put your timezone in the string in the [tt]lastmodified.js[/tt] file (if you modify it during Daylight Saving Time, put, for example &quot;GMT+1&quot;).

All yo really have to do is to remember to change the date and time in [tt]lastmodified.js[/tt] every time you update any of the pages on your site.

________________________________________
[hippy]Roger J Coult; Grimsby, UK
In the game of life the dice have an odd number of sides.
 
Any luck with this aboujouj83?

________________________________________
[hippy]Roger J Coult; Grimsby, UK
In the game of life the dice have an odd number of sides.
 
Thanks Woja! I finally found that the easier way is to just upload my index page each time i make any change, since it's a small file (few KB). But your method did work when I tried it...Thanks anyway

Aboujouj
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top