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 Coder
    Join Date
    Jan 2003
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    From today's links to other htmlpages after days.

    Hello,
    I am trying to master (?) JavaScript and I am a little bit in trouble now.
    On the "index.html" are a lot of links, each one leading to another html.page.
    How can I change (or redirect) to another html.page after a well defined period of time (ex. 5 or 12 days from now on).
    So people go automatically to another htmlpage (to see different content) from that specific date.


    I tried with the expression <body onLoad="fctionChange">.
    Trying to write this "fctionChange" I don't know how to handle the date of today and the date in the future.
    I guess it has something to do with " if .... else", but I'ts a hard time to make it work.
    Maybe I am wrong and it has nothing to do with the "onLoad"event.

    Can anyone of you please help me or give me some helpfull tips.
    Thanks a lot.

    I posted this thread earlier, but maybe I was not clear enough.
    Sorry.
    So I tried to explain it in another way.
    I hope this time it will work.

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    To retain continuity, your other thread can be found here which BTW, it would have been more appropriate to follow up on your original thread rather than starting another....

    And I'm afraid you are still not being clear enough...
    Providing an onLoad="fctionChange" event without any of the function codes does not assist towards helping us understand what is going on, let alone what you are trying to do...

    Perhaps it would be best if you posted a link...

    .....Willy

  • #3
    New Coder
    Join Date
    Jan 2003
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thank you neil9999 of the "WebDeveloper Forums".

    neil9999 of the "WebDeveloper Forums" (http://www.webdeveloper.com/forum/sh...650#post231650)
    found the solution.
    I was wrong to think that it had something to do with the onLoad event.

    Hereby you'll find the script so If other people are interested I hope they can use it.

    <script type="text/javascript">
    //Todays date
    a=new Date();
    //Date that hyperlink changes
    b=new Date("December 25, 2004 12:00:00");
    //converts times and dates into milliseconds
    a2=a.getTime();
    b2=b.getTime();
    //goes to google if after date, yahoo if before
    window.location=(a2>b2)?"http://www.google.co.uk":"http://www.yahoo.co.uk";
    </script>

    Again, thanks a lot for trying to help me.
    I still have a long way to go.

    And thank you very much: neil9999 of the "WebDeveloper Forums"

  • #4
    Regular Coder
    Join Date
    Aug 2002
    Location
    USA
    Posts
    625
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <script type="text/javascript">
    <!--
    
    current = new Date();
    expiration = new Date("August 24, 2004"); 
    
    if (current > expiration){
    window.location.href = "http://www.myDomain.com/newPage.html";
    }
    
    //-->
    </script>
    Doesn't take hours, minutes, seconds into account. So they will have a value of 00:00:00, or midnight. Just change the expiration date, and the link you want to forward to.


    Edit: Sorry, guess you beat me to it...well, my script is a little shorter...whatever. Glad you got it sorted.

    -james
    Last edited by jamescover; 08-19-2004 at 11:32 AM.
    "God so loved the world that he gave his only begotten son, so that whosoever believed in him would not perish, but have everlasting life. For God did not send his son into the world to condemn the world, but so that through him the world might be saved. "

  • #5
    New Coder
    Join Date
    Jan 2003
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Jamescover,

    thanks.
    Script is becoming more simple !! Where does it stop?
    Maybe you're right about the seconds and the milliseconds and is midnight the best time to change.
    I tried the previous script already and had some trouble with the time.
    The moment the script should change pages, it did not work.
    Maybe it is due to the fact that I live in the Netherlands and GMT (?).
    I'll try your script today and will let you know if it's ok .... and also if it's not ok
    Thank you very much.

  • #6
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Cheers for updating this thread to reflect the solution you found...

    ......Willy

  • #7
    New Coder
    Join Date
    Jan 2003
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    As promised

    Jamescover,

    As promised: it works !!!!
    Thanks

    Jef

  • #8
    Regular Coder
    Join Date
    Aug 2002
    Location
    USA
    Posts
    625
    Thanks
    0
    Thanked 0 Times in 0 Posts
    "God so loved the world that he gave his only begotten son, so that whosoever believed in him would not perish, but have everlasting life. For God did not send his son into the world to condemn the world, but so that through him the world might be saved. "


  •  

    Posting Permissions

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