473,836 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Display countdown

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

<script language="JavaS cript">
<!--

var tID = 0;
var startTime = null;

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

function UpdateTimer() {
if(tID) {
clearTimeout(tI D);
}
var date = new Date();
var diff = date.getTime() - startTime.getTi me();
if (diff >= timeout) {
focus();
window.open('/timeout.htm',"t imeout",'toolba r=0,location=0, directories=0,s ta
tus=0,menubar=0 ,scrollbars=0,r esizable=0,widt h=400,height=20 0');

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

--
(remove SPAMBLOCK if replying by e-mail)
Jul 23 '05 #1
6 1689
JRS: In article <0jjyc.9756$eu. 831@attbi_s02>, seen in
news:comp.lang. javascript, Michael <sa***@SPAMBLOC Kcuesplus.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="JavaS cript"> Deprecated ; should be <script type="text/javascript">.
<!-- Not inevitably superfluous.

tID = setTimeout("Upd ateTimer()", 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.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.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.de mon.co.uk> wrote in message
news:VL******** ******@merlyn.d emon.co.uk...
JRS: In article <0jjyc.9756$eu. 831@attbi_s02>, seen in
news:comp.lang. javascript, Michael <sa***@SPAMBLOC Kcuesplus.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="JavaS cript">

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

Not inevitably superfluous.

tID = setTimeout("Upd ateTimer()", 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.demo n.co.uk/js-index.htm> jscr maths, dates, sources. <URL:http://www.merlyn.demo n.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.co m...
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_s5 1>, seen in
news:comp.lang. javascript, Michael <mi**@mike.co m> 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
condescendin g.

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.demo n.co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demo n.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.de mon.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
4409
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 takes an extra 35 seconds, but has taken an extra 2.5 minutes in some cases. Any ideas what might be the cause? And more importantly - the fix? Code snippet below... Thanks, Christine
8
3787
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 help me find a way to stop it at zero? Thank you, Mike
31
14187
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
1774
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 number of seconds and this creates a DISPLAY of the form MM:SS (minutes:seconds)? Which i feel is more aesthetically pleasing to the intended users of the site. Kind regards Marc <HEAD>
4
3535
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 help.
1
3442
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 reaches zero, show the form which was hidden. I do not know how to do this and any help would be appreciated =]
0
2374
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 making some sort of game and I got stuck… :P I managed to get a clock counting down from 30 to 0 and then collect the score but I get in trouble when i try to make a button that restarts the procedure since i then get the doubled clock speed counting...
5
2541
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 that time countdown cannot be stop. 2) If i refresh the page means the countdown should comes from begining time. this is for Browser session time out countdown timer. Regards,
0
10818
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10526
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10565
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9348
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6972
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5641
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4436
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3999
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.