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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Mar 2005
    Location
    uk
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile 'redirect user between this date and this date' code ...

    Does anyone have a nifty bit of code I could 'borrow' please?

    I need to have an index page which redirects to THISindex.htm between specified dates (i.e. from 24 March 2005 until 29 March 2005) and on any other date THATindex.htm is displayed instead

    ... It doesn't need to be so accurate as to change at a certain time (though it would be handy to know this for the future)

    I have tried a couple of routes, but they just don't seem to work .. in fact, so far nothing happens at all, I just get the index page (with the code sitting doing nothing).

    Help?

    David
    Last edited by davidfarndon; 03-22-2005 at 08:20 PM.

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <script type="text/javascript">
     <!--//
      function checkDate(startDate,endDate,URL){
        if(new Date() >= new Date(startDate) && new Date() <= new Date(endDate))
           location.href = URL;
      }    checkDate('03/21/2005','03/29/2005','THISindex.html');
     //-->
    </script>
    If you want to redirect by a certain time you will need to jump thru a few more hoops...
    Try searching and reading up on: javascript date object....

    .....Willy

    Edit: Oooops... I did not notice your else THATindex.html...

    Code:
    <script type="text/javascript">
     <!--//
      function checkDate(startDate,endDate,URL){
        if(new Date() >= new Date(startDate) && new Date() <= new Date(endDate)){
           location.href = URL;
        }  else{ location.href = 'THATindex.html' };
      }    checkDate('03/21/2005','03/29/2005','THISindex.html');
     //-->
    </script>
    Last edited by Willy Duitt; 03-22-2005 at 09:43 PM.

  • #3
    New to the CF scene
    Join Date
    Mar 2005
    Location
    uk
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    FANTASTIC ...

    I owe you a pint.

    I shall insert and play .. but it looks like it will be just the job .. thanks Willie, you are a star!

    David

  • #4
    New to the CF scene
    Join Date
    Mar 2005
    Location
    uk
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    just to say that I installed this into an index page all of its own, and it worked like magic. I changed my system date and it sent me to the right page .. again .. spot on.

    so a BIG thank you.

    David


  •  

    Posting Permissions

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