473,386 Members | 1,610 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,386 software developers and data experts.

Display countdown

I would like to display the time counting down on a webpage when I use this
script.... Is it possible?

<script language="JavaScript">
<!--

var tID = 0;
var startTime = null;

var timeout=20*(60*1000) + 0*1000; // 20:00 minutes, as milliseconds

function UpdateTimer() {
if(tID) {
clearTimeout(tID);
}
var date = new Date();
var diff = date.getTime() - startTime.getTime();
if (diff >= timeout) {
focus();
window.open('/timeout.htm',"timeout",'toolbar=0,location=0,direc tories=0,sta
tus=0,menubar=0,scrollbars=0,resizable=0,width=400 ,height=200');

} else {
tID = setTimeout("UpdateTimer()", 1000);
}
}
function Start() {
startTime = new Date();
tID = setTimeout("UpdateTimer()", 1000);
}
// -->
</script>

--
(remove SPAMBLOCK if replying by e-mail)
Jul 23 '05 #1
6 1666
JRS: In article <0jjyc.9756$eu.831@attbi_s02>, seen in
news:comp.lang.javascript, Michael <sa***@SPAMBLOCKcuesplus.com> posted
at Fri, 11 Jun 2004 14:27:11 :
I would like to display the time counting down on a webpage when I use this
script.... Is it possible?
Since Number 3 page of the set referred to in the regularly-posted
newsgroup FAQ has a countdown until next Christmas noon, I suppose that
it must be. See signature.

<script language="JavaScript"> Deprecated ; should be <script type="text/javascript">.
<!-- Not inevitably superfluous.

tID = setTimeout("UpdateTimer()", 1000);


That will give a delay of 1000 ms plus overheads; some seconds will be
missed on at least some systems. It is surprisingly easy to recompute
the delay every time.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #2
Thank you Dr. Spock, but your convoluted answer, really isn't one.

Michael

--

(remove SPAMBLOCK if replying by e-mail)
"Dr John Stockton" <sp**@merlyn.demon.co.uk> wrote in message
news:VL**************@merlyn.demon.co.uk...
JRS: In article <0jjyc.9756$eu.831@attbi_s02>, seen in
news:comp.lang.javascript, Michael <sa***@SPAMBLOCKcuesplus.com> posted
at Fri, 11 Jun 2004 14:27:11 :
I would like to display the time counting down on a webpage when I use thisscript.... Is it possible?
Since Number 3 page of the set referred to in the regularly-posted
newsgroup FAQ has a countdown until next Christmas noon, I suppose that
it must be. See signature.

<script language="JavaScript">

Deprecated ; should be <script type="text/javascript">.
<!--

Not inevitably superfluous.

tID = setTimeout("UpdateTimer()", 1000);


That will give a delay of 1000 ms plus overheads; some seconds will be
missed on at least some systems. It is surprisingly easy to recompute
the delay every time.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE

4 © <URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript <URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources. <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items,

links.
Jul 23 '05 #3
Lee
Michael said:

Thank you Dr. Spock, but your convoluted answer, really isn't one.


He answered your question and, in addition, directed
you to an example and lots of useful information, and
also suggested improvements to your code.

If what you really wanted was for somebody to make the
changes to your code, you should have said so, and you
certainly should have responded more politely.

Jul 23 '05 #4
A question can be answered in a tone that any receiver can feel as though
they are being helped. In this case he came across not as helpful but
condescending.

I do not argue semantics but "...when I use this script.... Is it
possible?", is a statement that implies that I was talking about still using
the script, but just displaying it counting down. If I needed to be more
clear he could have replied as such with conversational English...

Michael
--

"Lee" <RE**************@cox.net> wrote in message
news:ca********@drn.newsguy.com...
Michael said:

Thank you Dr. Spock, but your convoluted answer, really isn't one.


He answered your question and, in addition, directed
you to an example and lots of useful information, and
also suggested improvements to your code.

If what you really wanted was for somebody to make the
changes to your code, you should have said so, and you
certainly should have responded more politely.

Jul 23 '05 #5
JRS: In article <cbazc.49050$Sw.48757@attbi_s51>, seen in
news:comp.lang.javascript, Michael <mi**@mike.com> posted at Mon, 14 Jun
2004 04:53:28 :
A question can be answered in a tone that any receiver can feel as though
they are being helped. In this case he came across not as helpful but
condescending.

I do not argue semantics but "...when I use this script.... Is it
possible?", is a statement that implies that I was talking about still using
the script, but just displaying it counting down. If I needed to be more
clear he could have replied as such with conversational English... "Lee" <RE**************@cox.net> wrote in message
...


Responses should go after trimmed quotes; evidently you have not yet
managed to study the newsgroup FAQ adequately.

If you post here, you need to realise that you are likely to be answered
in English. That is a language developed in my country; one which is
capable of exact expression (particularly when used by Dutch & Danes).
It is not, however, the American language, and you must learn to get
used to the difference (I suppose you are a Murican; your post gives no
positive indication, but most who are not choose to show that they are
not) in style.

The code that you posted cannot be used to give the desired effect; it
has a grammatical error due to your carelessness in posting. You have
allowed your posting agent to introduce a line break, which falls within
a string. When code is posted, it is for the poster to see that it will
be transmitted in executable form; your readers should not have to waste
time in sorting out superfluous adventitious deficiencies.

The code that you apparently tried is inadequate to give the desired
effect. It declares variables and functions, but calls for no
perceptible action.

If function Start is actually called, function UpdateTimer is (for no
obvious reason) called nearly once per second; and after 20 minutes it
attempts to open a window showing page /timeout.htm whatever that may
be. It is pointless to test with 20 minutes when 3 seconds will
obviously exercise all the code. Changing /timeout.htm to the name of a
page that I have, it does get loaded. (BTW, it would be slightly more
efficient to calculate the finish time only once, in function Start.)

But to display the time counting down on a Web page (well, you cannot,
since the time always increases; but I suppose you mean the interval
remaining until some future event), you either can follow the advice
previously given; or you can throw away most of your existing code and
ask again, stating your wishes more appropriately.

The task smells of being a piece set as coursework by a mediocre
educational institution.

--
© John Stockton, Surrey, UK. ??*@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
Check boilerplate spelling -- error is a public sign of incompetence.
Never fully trust an article from a poster who gives no full real name.
Jul 23 '05 #6
On Mon, 14 Jun 2004 18:22:17 +0100, Dr John Stockton
<sp**@merlyn.demon.co.uk> wrote:
If you post here, you need to realise that you are likely to be answered
in English. That is a language developed in my country; one which is
capable of exact expression (particularly when used by Dutch & Danes).
It is not, however, the American language, and you must learn to get
used to the difference (I suppose you are a Murican; your post gives no
positive indication, but most who are not choose to show that they are
not) in style.


"Doctor", you would be much better served, and taken much more
seriously, if you kept you bigotry to yourself.
Jul 23 '05 #7

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

Similar topics

4
by: Christine | last post by:
I've implemented a countdown timer for a tutorial web page that should give the user 45 minutes to complete the test, only to find that the timer is slowly 'losing' time. On average, it actually...
8
by: Michael | last post by:
I have this script that works the way I want except for one thing... Once it hits zero it starts to count up and looks like this: -1:0-1:0-1:0-18 with the last number counting up. Can anyone...
31
by: Stephanie | last post by:
I have a newbie question (couldn't find the answer with google) How to show countdown from 10 to 0 seconds. Stephanie
2
by: libsfan01 | last post by:
Hi all! I have this javascript timer which counts down the number of secs that i put in and then then redirects my page, what i want to know is how to i modify the code so that i can input the...
4
by: henrik | last post by:
Hi. Can anyone tell me the python code for a simple countdown from eg. 2.00 minutes. It should be printet out to the screen. When it is finished it should write "Time is up" Hope you can...
1
by: 40esp | last post by:
Im trying to make my site more secure and to stop spammers.. in my <div> I have a form with textboxes. I want to do this. I want it to countdown for 10 seconds, and then when the countdown...
0
by: Jorhajnes | last post by:
Hi there. Im very new to making games in flash, although I have used flash for quite some time now in web-based situations so I know my way around. Anyways, I thought it would be fun to try...
5
mageswar005
by: mageswar005 | last post by:
hi, I need a javascript countdown timer to my website, I have already the countdown timer but its have some problem. Note: 1) If i choose the tools/internet option in my browser means , at...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.