Results 1 to 2 of 2

Thread: night loads index2 daytime loads index1

  1. #1
    Join Date
    Jan 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post night loads index2 daytime loads index1

    1) Script Title: Day & night script

    2) Script URL (on DD): not available

    3) Describe problem: i know how to read javascript, but only when i see it :-(

    I'd really like a script that reads the computers time when the index is loaded and redirects to index1 @daytime and to index2 @night and can easily be changed depending on how early it gets dark

    The only script i've ever made is this css stylesheetchanger based on resolution check:

    Code:
    <script type="text/javascript" language=JavaScript>
    if (screen.width>1599)
      document.write('<link rel="stylesheet" type="text/css" href="../../../css/ie1600standaard.css">');
    if (screen.width<1281)
      document.write('<link rel="stylesheet" type="text/css" href="../../../css/ie1280standaard.css">');
    if (screen.width<1025)
      document.write('<link rel="stylesheet" type="text/css" href="../../../css/ie1024standaard.css">');
    </SCRIPT>
    I was thinking i need about the same thing with a clock and the
    Code:
    <link rel="stylesheet" type="text/css" href="../../../css/xxx.css">
    replaced bij

    Code:
    window.location = "http://www.starthemel.nl/index1"
    Code:
    window.location = "http://www.starthemel.nl/index2"
    depending on the time.

    Can anyone please help me out?
    Last edited by llr; 01-29-2009 at 04:38 AM.

  2. #2
    Join Date
    Jan 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Solution

    I can't believe it, but i actually found it:

    Code:
    <script language="JavaScript">
    <!--
    var now = new Date(  );
    var hour = now.getHours(  );
    if (hour >= 7 && hour <= 20) {
    window.location = "http://www.example.nl/day"}
    else {
    window.location = "http://www.example.nl/night"}
    //-->
    </script>
    Last edited by llr; 01-29-2009 at 02:42 PM.

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
  •