Results 1 to 2 of 2

Thread: Time-Based Page Switching

  1. #1
    Join Date
    Nov 2006

    Time-Based Page Switching

    Hi guys,

    I'm new to Javascript, so a more detailed explanation would be appreciated. I'm trying to create a splash page that looks different based on the time of day. I'd like to do this by having two different HTML pages and have a javascript file detect the user's time of day and direct them to the appropriate page. Any code and/or implementation would be greatly appreciated. Thanks again.

  2. #2
    Join Date
    Jun 2004
    United States (Currently in Iraq)
    Here is an example that will display one page if the current time is less than 1200 hrs and then another if the current time is greater than or equal to 1200 hrs:

    <script type="text/javascript">
      window.onload = function() {
        var currDate = new Date();
        if (currDate.getHours() < 12) {
          location.href = "your link here";
        } else {
          location.href = "your link here";

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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