473,396 Members | 1,935 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Scripted Updated Indicator

I use the following piece of code to show when the page thats being accessed was
last updated:

<!--
var modified = new Date(document.lastModified);
document.write("<b>Last Updated:<i> "+modified+"</I></B>");
// -->

This works great, but it only does it for the page thats currently displayed.

Is there some way to possibly get my main page to show an updated indicator
likie:
some page link <UPDATED> then date/time

Where <updated> is an animated gif I use that flashes updated.

I've been doing this by hand for my main page, but would like to automate it so
that if the page has been updated within say the last 5 days it would
automatically add this flashing graphic and the date/time next to the link for
the page.

Thanks for any pointers.

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Jul 23 '05 #1
1 1645
xx***********@tampascanner.info wrote:
I use the following piece of code to show when the page thats being accessed was
last updated:

<!--
var modified = new Date(document.lastModified);
document.write("<b>Last Updated:<i> "+modified+"</I></B>");
// -->
Hiding scripts is unnecessary and potentially harmful, don't do it.

This works great, but it only does it for the page thats currently displayed.
It will also only work if the user has JavaScript enabled. Not to be
picky, but why does it need to work on pages that aren't currently
displayed? :-)

Oh, I get it (I'm a bit slow this morning), you mean it doesn't work
for resources indicated by URI's.

So your dilema is that you want to determine the last modified date of
the resource at the end of the link, not the current document. And to
do that reliably is probably beyond the capability of any browser (note
that the content may have changed even if the actual HTML file that
hosts the content has not - e.g. modified images or dynamic content).

For more (general) information on lastModified, read the group FAQ:

<URL:http://www.jibbering.com/faq/#FAQ4_30>

Is there some way to possibly get my main page to show an updated indicator
likie:
some page link <UPDATED> then date/time

Where <updated> is an animated gif I use that flashes updated.
Flashing gifs ...ugghhh! They are truely despised, please reconsider.
Also, if the user has images turned off, they won't see the gif.

Anyway, let's proceed on the assumption that you will just place an
attractive 'New' gif (or just coloured text) next to links that point
to content less than 5 days old.

How you determine the period depends on how accurately you want to
measure your 5 days. By far the simplest method is to work it out at
your server and just add the appropriate highlight before sending the
page. You are then insulated from the vaguaries of client systems and
the accuracy of their internal clock.

If you're going to trust the client system's clock, you can send a date
object in your file, create a 'now' date object at the client, convert
them both to the same reference system (say UTC), find the difference
and if it's greater than 4.32e8 (the number milliseconds in 5 days)
show the highlight. That is likely not exact, but near enough for
now.

You could include a string in the value of some attribute of each link
(say in the class) that represents the date last modified of the linked
resource and can be converted into a date object. A script could
extract the value, convert it, compare it to 'now' and conditionally
add the highlight.

But for all that effort you may as well just add the highlight at the
server instead of the embedded date string, avoiding client-side
issues. Your server can get the last modified timestamp for linked
resources without your intervention, so that part is catered for too
(but the issue of updated content in the linked resource is not).

The server script would likely be no more complex than a client
script of similar functionality.

I've been doing this by hand for my main page, but would like to automate it so
that if the page has been updated within say the last 5 days it would
automatically add this flashing graphic and the date/time next to the link for
the page.


A client-side, script-dependant, unreliable solution is likely not
suitable when a better server side solution is availabe.
--
Fred
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Koen Janssens | last post by:
Can anybody give me an example on how to write a progress indicator in C++ using the standard library cerr or cout? My problem is I do not know how reset the output stream to the beginning of...
6
by: DebbieG | last post by:
I have created a database for a client and was told that it was to be a one-user database. Well, you know the next statement ... now they want 3 people to be able to use the database. (FYI, I...
4
by: vulcaned | last post by:
Hi All, Hopefully I explain this well........ In Access97 I have a form which has a tab control on it, each tab has a sub-form which is bound to its appropriate table(I'll call them 'Detail'...
7
by: Andrew | last post by:
Hello, Is it possible for a file position indicator of an input stream to be greater than the size of a file? And if so could this cause fgetc to somehow write to the file? For example is it...
1
by: Bob | last post by:
I have a common assembly installed into the GAC and is referenced by most of my ASP.NET projects. This is fine for compiled web applications as the reference to the assembly is added in the Visual...
1
by: Marko Vuksanovic | last post by:
I am trying to implement a file upload progress indicator (doesn't have to be a progress bar) using atlas... I do realize that the indicator cannot be implemented using Update panel control, but is...
6
by: Marko Vuksanovic | last post by:
I am trying to implement a file upload progress indicator (doesn't have to be a progress bar) using atlas... I do realize that the indicator cannot be implemented using Update panel control, but is...
14
by: Frank Swarbrick | last post by:
A few weeks ago I had posed a question about how one my create a cursor for a query where the predicate condition is dynamic. Meaning that the query might want to have one of several possible...
80
by: nicolas.sitbon | last post by:
Hi everybody, in a french C book, the author says that only {fgetc, getc, getchar, fgetwc, getwc, getwchar, fgets, gets, fgetws, getws, fputc, putc, putchar, fputwc, putwc, putwchar, fputs, puts,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.