Results 1 to 5 of 5

Thread: Code to auto refresh page every day?

  1. #1
    Join Date
    Jan 2009
    Location
    NH
    Posts
    675
    Thanks
    98
    Thanked 26 Times in 26 Posts

    Question Code to auto refresh page every day?

    I was looking for a code to refresh a web page every day for repeat visitors in case of any changes that were made.

    I would like it to work on all systems and browsers. Is this even possible?

    This is one thing that I have found.

    HTML Code:
    <META HTTP-EQUIV="refresh" CONTENT="86400">"
    The "86400" part of the code instructs the browser to reload the current page every 86,400 seconds, which is once a day

    Or would something with javascript be a better option?

    HTML Code:
    <!-- Codes by Quackit.com -->
    <html>
    <head>
    <script type="text/JavaScript">
    <!--
    function timedRefresh(timeoutPeriod) {
    	setTimeout("location.reload(true);",timeoutPeriod);
    }
    //   -->
    </script>
    </head>
    <body onload="JavaScript:timedRefresh(5000);">
    <p>This page will refresh every 5 seconds. This is because we're using the 'onload' event to call our function. We are passing in the value '5000', which equals 5 seconds.</p>
    <p>But hey, try not to annoy your users too much with unnecessary page refreshes every few seconds!</p>
    </body>
    </html>
    of course I would want to change 5000


    thanks

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    That sounds annoying (just being honest). Visitors would not understand and if the page changed randomly while they were sleeping (or worse, trying to read it), that would be confusing.
    I understand a relatively-constantly updating page, but if it's static for 24 hours then randomly reloads, that's odd.

    Why not use Ajax for a specific portion of the site to reload more often than that? Maybe a news area that reloads every hour. That seems more reasonable.

    Both options you posted above are fine. The meta option will be a little more reliable and it's harder to disable.

    But there's a bigger issue: that's going to refresh every 24 hours--- any 24 hours. If you want it to refresh for every new day at midnight, you'll need to use Javascript to figure out when that is, and hope everyone is in the same timezone. Or you could use PHP or another serverside language to generate the right number of seconds until the next day for the server (constant for everyone). If you just randomly have it refresh every 24 hours, it might take up to 23 hours 59 minutes for someone to see your updates... there's no way of knowing.

    And finally: why would anyone stay on your page for 24 hours in a row? I don't do that with any websites (except my email-- gmail).
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Jan 2009
    Location
    NH
    Posts
    675
    Thanks
    98
    Thanked 26 Times in 26 Posts

    Default

    The guy who's website I've been doing for a while was asking about it. He is pretty sure he want's a page he can use sort of like a news page. I really don't imagine him updating more than once a day, so that's why I said day in my time frame mentioned.

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    But again, if he updates it at 3pm and the page is set to refresh at 2pm, then it will be 2pm the next day, 23 hours after the news was updated. Even if the news does not actually update that often, it's probably more useful to update it every hour (10 minutes? 2 hours? whatever you want) than 24 hours since that's impractical. Again, who will actually stay on the page that long? Unless this is just for him to play with (and I understand-- I like playing with my own websites), it doesn't seem very helpful.

    For that sort of situation, I'd again recommend some sort of Ajax, and hopefully one that is a little fancy: it could slide the new messages in so there is some sort of visual cue about an update. That would make the transition a lot less weird. You could based this on a "chat" script model, just a very slow, one-sided conversation.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. #5
    Join Date
    Jan 2009
    Location
    NH
    Posts
    675
    Thanks
    98
    Thanked 26 Times in 26 Posts

    Default

    That sounds pretty OK. Do you have any scripts here to help me do that?

    edit: I just found some in DD, looking at them now.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •