Results 1 to 7 of 7

Thread: Load new page on monday of each week

  1. #1
    Join Date
    Apr 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Load new page on monday of each week

    Hello,

    I'm trying to find a script that will allow me to load an different external page each week. Basically there are 12 different html pages that need to be rotated every Monday as the index file. Right now I am manually renaming each page to index.html when it is it's turn to be shown. Does anyone know of a script that will do this automatically for me?

    I found this, http://www.dynamicdrive.com/dynamici...ajaxrotate.htm but it looks like it can only rotate pages every day of a week or month. Any help is much appreciated. Thanks!

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    You could just use one of those rotate scripts and seed it with repeating values for each day, changing it every 7.

    However, if you want to make your own script, the best idea is to look into PHP (or ASP etc), which would fairly easily allow for this. I'd suggest a simple database and PHP setup, which wouldn't be too hard.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Apr 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for the reply djr. Unfortunately I'm far from programming literate. Do you know of any resources or links that could point me in the right direction? Thanks again for the help!

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Here's a script that I just wrote up that will replace its page with a page numbered from 0 to 11 based upon which number of Mondays has passed in a given year. As configured, these would be:

    weekly0.htm
    weekly1.htm
    weekly2.htm
    weekly3.htm
    weekly4.htm
    weekly5.htm
    weekly6.htm
    weekly7.htm
    weekly8.htm
    weekly9.htm
    weekly10.htm
    weekly11.htm

    Here's a demo:

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script type="text/javascript">
    
    /* Fetch pages based upon Mondays Since January 1st
     * &#169; John Davenport Scheuer
     * This notice must remain for legal use */
    
    var basePageName='weekly'; //set to base name of pages
    var basePageExt='htm'; //set extension of base pages
    var numPages=12; //set to number of weekly pages
    
    ////////////////// Stop Editing //////////////////
    var now=new Date(), curMonday, yr=now.getFullYear(), firstOfYear=new Date(yr, 0, 1);
    var dt=now.getDate(), ft=1, baseMonday; numPages--;
    now=new Date(yr,now.getMonth(),dt);
    if(now.getDay()!=1)
    while (now.getDay()!=1)
    curMonday=now.setDate(dt--);
    else
    curMonday=now.setDate(dt);
    if(firstOfYear.getDay()!=1)
    while(firstOfYear.getDay()!=1)
    baseMonday=firstOfYear.setDate(ft++);
    else
    baseMonday=firstOfYear.setDate(ft);
    var Mondays=Math.floor((curMonday-baseMonday)/(1000*60*60*24*7))
    if(Mondays>numPages)
    while (Mondays>numPages)
    Mondays-=numPages;
    if(Mondays<0)
    Mondays=0;
    if(window.location.replace)
    window.location.replace(basePageName+Mondays+'.'+basePageExt);
    else
    window.location.href=basePageName+Mondays+'.'+basePageExt;
    </script>
    </head>
    <body>
    Your browser is not currently supporting javascript. Please select from one of the below:<br>&nbsp;<br>
    <a href="weekly0.htm">Weekly &nbsp;0</a><br>
    <a href="weekly1.htm">Weekly &nbsp;1</a><br>
    <a href="weekly2.htm">Weekly &nbsp;2</a><br>
    <a href="weekly3.htm">Weekly &nbsp;3</a><br>
    <a href="weekly4.htm">Weekly &nbsp;4</a><br>
    <a href="weekly5.htm">Weekly &nbsp;5</a><br>
    <a href="weekly6.htm">Weekly &nbsp;6</a><br>
    <a href="weekly7.htm">Weekly &nbsp;7</a><br>
    <a href="weekly8.htm">Weekly &nbsp;8</a><br>
    <a href="weekly9.htm">Weekly &nbsp;9</a><br>
    <a href="weekly10.htm">Weekly 10</a><br>
    <a href="weekly11.htm">Weekly 11</a><br>&nbsp;<br>
    
    Or, you may enable javascript and hit refresh.
    </body>
    </html>
    Last edited by jscheuer1; 04-11-2007 at 05:18 AM. Reason: Add non-javascript fall back code, correct math
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Apr 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks jscheuer1!!! I'm going to test this out right now. Thanks again for all your help

  6. #6
    Join Date
    Apr 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hey jsc, just wanted to let you know that I've implemented the script you wrote and it works perfectly. Thanks again for your help, you've saved me tons of time!

  7. #7
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by greenday45 View Post
    Hey jsc, just wanted to let you know that I've implemented the script you wrote and it works perfectly. Thanks again for your help, you've saved me tons of time!
    Not so fast! I had tried checking the script earlier by resetting my system date but, that caused problems with some of my browsers and the situation got confused, I was tired, so I gave it my best shot. I just now realized I could set the 'current' date in the script for testing purposes. This eliminated any problems with the browsers. As a result I have updated the math one last time - see corrected script in the original post. This mostly only comes into play if you are at or near a Monday, or are in Daylight Savings Time.
    Last edited by jscheuer1; 04-11-2007 at 05:41 AM. Reason: Date Still off, correcting
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

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
  •