Display countdown

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael

    #1

    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)


  • Dr John Stockton

    #2
    Re: Display countdown

    JRS: In article <0jjyc.9756$eu. 831@attbi_s02>, seen in
    news:comp.lang. javascript, Michael <sales@SPAMBLOC Kcuesplus.com> posted
    at Fri, 11 Jun 2004 14:27:11 :[color=blue]
    >I would like to display the time counting down on a webpage when I use this
    >script.... Is it possible?[/color]

    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.

    [color=blue]
    ><script language="JavaS cript">[/color]
    Deprecated ; should be <script type="text/javascript">.
    [color=blue]
    ><!--[/color]
    Not inevitably superfluous.

    [color=blue]
    > tID = setTimeout("Upd ateTimer()", 1000);[/color]

    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.

    Comment

    • Michael

      #3
      Re: Display countdown

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

      Michael

      --

      (remove SPAMBLOCK if replying by e-mail)
      "Dr John Stockton" <spam@merlyn.de mon.co.uk> wrote in message
      news:VLYJeQBBxi yAFwo1@merlyn.d emon.co.uk...[color=blue]
      > JRS: In article <0jjyc.9756$eu. 831@attbi_s02>, seen in
      > news:comp.lang. javascript, Michael <sales@SPAMBLOC Kcuesplus.com> posted
      > at Fri, 11 Jun 2004 14:27:11 :[color=green]
      > >I would like to display the time counting down on a webpage when I use[/color][/color]
      this[color=blue][color=green]
      > >script.... Is it possible?[/color]
      >
      > 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.
      >
      >[color=green]
      > ><script language="JavaS cript">[/color]
      > Deprecated ; should be <script type="text/javascript">.
      >[color=green]
      > ><!--[/color]
      > Not inevitably superfluous.
      >
      >[color=green]
      > > tID = setTimeout("Upd ateTimer()", 1000);[/color]
      >
      > 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[/color]
      4 ©[color=blue]
      > <URL:http://jibbering.com/faq/> Jim Ley's FAQ for[/color]
      news:comp.lang. javascript[color=blue]
      > <URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates,[/color]
      sources.[color=blue]
      > <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items,[/color]
      links.


      Comment

      • Lee

        #4
        Re: Display countdown

        Michael said:[color=blue]
        >
        >Thank you Dr. Spock, but your convoluted answer, really isn't one.[/color]

        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.

        Comment

        • Michael

          #5
          Re: Display countdown

          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" <REM0VElbspamtr ap@cox.net> wrote in message
          news:cadqlt0p74 @drn.newsguy.co m...[color=blue]
          > Michael said:[color=green]
          > >
          > >Thank you Dr. Spock, but your convoluted answer, really isn't one.[/color]
          >
          > 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.
          >[/color]


          Comment

          • Dr John Stockton

            #6
            Re: Display countdown

            JRS: In article <cbazc.49050$Sw .48757@attbi_s5 1>, seen in
            news:comp.lang. javascript, Michael <mike@mike.co m> posted at Mon, 14 Jun
            2004 04:53:28 :[color=blue]
            >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...[/color]
            [color=blue]
            >"Lee" <REM0VElbspamtr ap@cox.net> wrote in message
            > ...[/color]

            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.

            Comment

            • Frederic Banaszak

              #7
              Re: Display countdown

              On Mon, 14 Jun 2004 18:22:17 +0100, Dr John Stockton
              <spam@merlyn.de mon.co.uk> wrote:
              [color=blue]
              >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.
              >[/color]

              "Doctor", you would be much better served, and taken much more
              seriously, if you kept you bigotry to yourself.


              Comment

              Working...