View Full Version : Load new page on monday of each week
greenday45
04-09-2007, 08:47 PM
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/dynamicindex17/ajaxrotate.htm but it looks like it can only rotate pages every day of a week or month. Any help is much appreciated. Thanks!
djr33
04-09-2007, 11:06 PM
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.
greenday45
04-10-2007, 12:18 PM
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!
jscheuer1
04-10-2007, 02:27 PM
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:
<!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
* © 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> <br>
<a href="weekly0.htm">Weekly 0</a><br>
<a href="weekly1.htm">Weekly 1</a><br>
<a href="weekly2.htm">Weekly 2</a><br>
<a href="weekly3.htm">Weekly 3</a><br>
<a href="weekly4.htm">Weekly 4</a><br>
<a href="weekly5.htm">Weekly 5</a><br>
<a href="weekly6.htm">Weekly 6</a><br>
<a href="weekly7.htm">Weekly 7</a><br>
<a href="weekly8.htm">Weekly 8</a><br>
<a href="weekly9.htm">Weekly 9</a><br>
<a href="weekly10.htm">Weekly 10</a><br>
<a href="weekly11.htm">Weekly 11</a><br> <br>
Or, you may enable javascript and hit refresh.
</body>
</html>
greenday45
04-10-2007, 06:23 PM
Thanks jscheuer1!!! I'm going to test this out right now. Thanks again for all your help :)
greenday45
04-10-2007, 09:29 PM
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!
jscheuer1
04-11-2007, 04:16 AM
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.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.