Refresh every minute, on the minute.

Discussion in 'Java' started by Denebola, Feb 27, 2006.

  1. Denebola

    Denebola Guest

    I am trying to refresh my webpage every minute, on the minute and so
    far have the script below in the <head> of my page:

    <SCRIPT LANGUAGE="JavaScript"><!--
    function startTimer() {
    var now = new Date();
    var minutes = now.getMinutes();
    var seconds = now.getSeconds();
    setTimeout('refresh()',(((((seconds>0)?1:0)) * 60) + (60 -
    seconds)) * 1000);
    }

    function refresh() {
    window.location.href = 'http://www.bbc.co.uk';
    }

    startTimer();
    //--></SCRIPT>

    The problem is that if i visit this page at say 25 seconds past the
    minute, it won't refresh at the next minute change (in 35 seconds) but
    will wait til the next minute to do so (i.e. in 95 seconds).

    Where am I going wrong......??

    Regards
     
    Denebola, Feb 27, 2006
    #1
    1. Advertising

  2. Denebola

    Chris Smith Guest

    Denebola <> wrote:
    > I am trying to refresh my webpage every minute, on the minute and so
    > far have the script below in the <head> of my page:
    >
    > <SCRIPT LANGUAGE="JavaScript"><!--


    You want comp.lang.javascript. This is comp.lang.java.programmer.

    --
    www.designacourse.com
    The Easiest Way To Train Anyone... Anywhere.

    Chris Smith - Lead Software Developer/Technical Trainer
    MindIQ Corporation
     
    Chris Smith, Feb 27, 2006
    #2
    1. Advertising

  3. Denebola

    Guest

    Have you tried to use the <META http-equiv refresh>? Here is an
    example:

    <meta http-equiv="Refresh" content="n;url">

    Put this meta tag inside your html <head> tag.

    Where n is the number of seconds to wait before refreshing and url is
    the url to be reloaded.

    Regards,
    I Wayan Saryada
     
    , Feb 27, 2006
    #3
  4. Denebola

    Denebola Guest

    Chris Smith wrote:
    > You want comp.lang.javascript. This is comp.lang.java.programmer.


    Oops...my apologies..... I'll try there... thank you.
     
    Denebola, Feb 27, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Laszlo Szijarto

    refresh a page every so often

    Laszlo Szijarto, Jul 1, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    401
    Laszlo Szijarto
    Jul 2, 2003
  2. Kevin
    Replies:
    3
    Views:
    643
    S. Justin Gengo
    Sep 30, 2005
  3. CB
    Replies:
    8
    Views:
    4,818
  4. =?Utf-8?B?SXJ3YW5zeWFo?=
    Replies:
    4
    Views:
    2,466
    =?Utf-8?B?SXJ3YW5zeWFo?=
    Oct 30, 2007
  5. Jeff Clark
    Replies:
    15
    Views:
    212
    Jeff Cochran
    Nov 20, 2003
Loading...

Share This Page