Results 1 to 3 of 3

Thread: Display page depending on day/night; script anyone?

  1. #1
    Join Date
    Sep 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Display page depending on day/night; script anyone?

    Hey I was wondering if any one knew of a script for displaying a certain page when visiting a site depending on night or day on the local machine. I've found them for showing certain images, but I was looking for a script where a night home page or a day home page would be displayed.

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    This should work:
    Code:
    <script type="text/javascript">
    window.onload = function(){
    var hour = new Date().getHours();
    var time;
    if(hour > 11){
    window.location.href="http://www.example.com/night";
    } else {
    window.location.href="http://www.example.com/morning";
    }
    }
    </script>
    Jeremy | jfein.net

  3. #3
    Join Date
    Jul 2008
    Posts
    40
    Thanks
    1
    Thanked 4 Times in 4 Posts

    Default

    Just a quick example on how to load different pages depending to night and day!
    Hope this would help you up!
    If the current time is equals to 6pm, then this code will load the night page!



    This should go along with your daypage.html!
    Code is as follows:

    Code:
    <html>
    <head>
    <title>Day Page</title>
    
    <script type="text/javascript">
    <!-- 
    window.onload = function()
    { var today = new Date();
      var hour = today.getHours();
     if ( hour  >= 18 && hour <= 6 ) { window.open('somenightpage.html', target='_self', 'toolbar = yes, scrollbars = yes, location = yes'); return false; } else { return true; }  
    }
    //-->
    </script>
    </head>
    <body>
    <p>Day Page!<
    </body>
    </html>

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
  •