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 3 of 3
  1. #1
    New Coder
    Join Date
    Mar 2013
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up script change over

    hi there i would like to know if anyone knows of any coding were it can change scripts over at certain times of day. for exmaple

    6 till 12
    <center><a href="http://destiny106.co.uk/requests/rabbitrequest.php" target="_blank">
    <img src="http://www.destiny106.co.uk/djonair/reqs/rabbit.png" border="2" style="border:2px solid black;max-width:100%;" alt="destiny!" />
    </a></center>

    then 12 till 3

    <center><a href="http://destiny106.co.uk/Request.html" target="_blank">
    <img src="http://destiny106.co.uk/djonair/reqs/ultra.png" border="2" style="border:2px solid black;max-width:100%;" alt="destiny!" />
    </a></center>

    then 3 till 7
    <center><a href="http://destiny106.co.uk/requests/devilrequest.php" target="_blank">
    <img src="http://destiny106.co.uk/djonair/reqs/devil.png" border="2" style="border:2px solid black;max-width:100%;" alt="destiny!" />
    </a></center>

    if anyone could help me out that would be great!!!
    Last edited by djultra; 04-06-2013 at 03:23 PM.

  • #2
    New Coder
    Join Date
    Feb 2007
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi!

    I have found something and hope this may in some way helpful.

    <html>
    <script type="text/JavaScript">

    function timedRefresh()
    {
    var x="";
    var time=new Date().getHours();

    if (time>6&&time<12)
    {
    window.open('http://destiny106.co.uk/requests/rabbitrequest.php ','mywindow','width=400, other attributes); // bra bra ……..
    }
    else if (time>12&&time<15)
    {
    window.open('http://destiny106.co.uk/djonair/reqs/ultra.png ','mywindow','width=400, other attributes); // bra bra ……..
    }
    else
    {
    window.open('http://destiny106.co.uk/requests/devilrequest.php ','mywindow','width=400, other attributes, other attributes); // bra bra ……..
    }
    }
    </script>
    <body>
    <body onload="JavaScript:timedRefresh(60000);">
    </body>
    </html>

  • #3
    Banned
    Join Date
    Mar 2013
    Posts
    139
    Thanks
    0
    Thanked 9 Times in 9 Posts
    Doing this with javascript is a bad idea because

    1 - you are assuming javascript is turned on the user's browser and it might not be

    2 - you are using the time on the user's device which might not be accurate.

    A much better way to do this is server side, say with php etc, and get the server time when the page is requested, adjust for the user's timezone if you want to and then get php to output the appropriate html for the time of day.

    No need for javascript at all.


  •  

    Posting Permissions

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