Solved

Permanent VARIABLES and "Smart Countdown" ?

Posted on 1997-11-03
3
338 Views
Last Modified: 2008-03-06
I have created a small program which shows the minutes left to the top of the hour (ie. if it's 9:34pm right now, the count down show: 00:26 mins left).  I used the <IMG> command to call my CGI script which sends back binary data of a GIF picture corresponding to the correct digits of the minutes left.  So it looks like I have a "graphical" countdown of the minutes left.  

I use Javascripting to call a function every 1 minute.  In this function it makes a recall to my CGI script to get the *present* minutes left.  This way the counter is counting down graphically every minute.  

I want the user of my web site to have the ability to refresh the screen, leave my web site and BACK up to it at a later time, and to ALWAYS see my countdown at the EXACT minutes left before the hour.  I achieved this with always calling my CGI script to get the latest minutes left.  Unfortunately, I want ONE more thing.  I want the countdown to countdown to 00:00 and never go past this!  As soon as it hits 00:00 it pops up a new graphic to tell user to RELOAD the web page since it is old.  

Now if the user is allowed to leave my web site and is allowed to back up to see the NEW minutes left before the hour, he could leave my web site for DAYS and then back up to it seeing the new minutes left before the hour, but 00:00 of the hour he really came in had long passed.  The graphic that should pop up would never pop up until 00:00 is reached for this hour.

Is there anyway I can use a PERMANENT VARIABLE in Javascripting (persists even if the user leaves my web site) which can store some useful data to solve this problem?  Or is there another trick I can use to make sure the user gets the graphic: RELOAD THIS WEB PAGE, because the end of the hour when you arrived has lapsed?????



0
Comment
Question by:ljaques
3 Comments
 
LVL 6

Expert Comment

by:alamo
ID: 1272402
The "permanent variable" you refer to exist- cookies. You can read and write cookies from javascript. You can also read and write cookies from a .pl. When your script returns a countdown digit it could set a cookie that gives the time to pop up the "reload" message. Whenever the countdown digits are loaded, if the cookie sees the "reload" message time is past it could send the reload graphic.

Be aware though that a lot of people hate cookies and have them turned off, so this won't always work and will annoy some people. I haven't checked whether the "ask before accepting cookie" flag applies to javascript too, though I would assume so.

If your entire page is produced by a script, you could set the expires time to the top of the hour, which is probably a cleaner way of handling this.

let me know when you get some points :-)
0
 
LVL 1

Accepted Solution

by:
malec earned 0 total points
ID: 1272403
Another option is to use Perl script to save var value to file on a server but you'll need to associate every such file with the user (I would use his IP address for that). Advantage - no need for cookies and, therefore, reliability, because you don't have to depend on users acceptence of the cookie. Disadvantage - number of files can grow indefinitely. The whole thing will take just coule of lines in perl.
0
 

Author Comment

by:ljaques
ID: 1272404
Adjusted points to 5
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question