Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Jun 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need script for redirecting based on fixed time

    Need script for redirecting based on fixed time

    I am looking for a small script that can redirect to a url based on a fixed time.. Lets say 06:00 o'clock.
    The script wil be placed in a index and the index will run the whole day.. until it reach the time of 06:00 and it redirect it too another url..

    Who can write this..?

    p.s. i found something simulair here: Cut & Paste JavaScript Alarm clock



    Thanks in advance

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,151
    Thanks
    203
    Thanked 2,548 Times in 2,526 Posts
    Bear in mind that times in Javascript are taken from the user's clock, so a server-side solution would be better if accuracy is required.

    Code:
    <body onload = setInterval(timer,10000)>
    
    <script type = "text/javascript">
    
    function timer() {
    var tim = new Date().getHours();
    if (tim >=6) {
    window.location = "http://www.google.com";
    }
    }
    
    </script>
    
    </body>

    The timer script runs every 10 seconds, assumed to be accurate enough. You can alter that if you want.

    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.
    Last edited by Philip M; 06-18-2014 at 12:54 PM.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #3
    New Coder
    Join Date
    Jun 2014
    Posts
    23
    Thanks
    0
    Thanked 2 Times in 2 Posts
    You can also do it by using "refresh meta tag"

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,151
    Thanks
    203
    Thanked 2,548 Times in 2,526 Posts
    Quote Originally Posted by code_generator View Post
    You can also do it by using "refresh meta tag"
    I don't see how you can do that to redirect at or after a specific time.
    Last edited by Philip M; 06-21-2014 at 08:06 AM.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #5
    Regular Coder
    Join Date
    May 2012
    Location
    France
    Posts
    224
    Thanks
    0
    Thanked 32 Times in 30 Posts
    Simply
    <meta http-equiv="refresh" content="5;URL=/newPage.html">

  • #6
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,151
    Thanks
    203
    Thanked 2,548 Times in 2,526 Posts
    Quote Originally Posted by 007julien View Post
    Simply
    <meta http-equiv="refresh" content="5;URL=/newPage.html">
    As I say, I don't see how you can do that to redirect at or after a specific time.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #7
    Regular Coder
    Join Date
    May 2012
    Location
    France
    Posts
    224
    Thanks
    0
    Thanked 32 Times in 30 Posts
    Expand a little prospects !
    Regardless of the javascript solution, it is always possible to display two meta tags : one too solve the problem after a specific time and one other, build with a server language like php, at a specific server time...

  • #8
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,151
    Thanks
    203
    Thanked 2,548 Times in 2,526 Posts
    Oui, mon vieux choux. But that is not at all appropriate for someone who is a newomer here with 1 post. He wanted a Javascript solution. N'est-ce pas?

    I did say "Bear in mind that times in Javascript are taken from the user's clock, so a server-side solution would be better if accuracy is required."

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.


  •  

    Posting Permissions

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