View Full Version : Scheduled Content

12-07-2008, 03:05 PM
Hello, I would like to find/make a JavaScript that loads content based on week of the year. Is that possible? Each piece of content is just a couple lines of text so it would be nice to keep it all in the same file. The script should check what week it is and display the content on a repeating annual schedule.

Is this possible? If you have any suggestions/scripts/ideas please tell me!

It must be JavaScript. I use .Mac/MobileMe web hosting and I don't think it does PHP.


12-07-2008, 03:29 PM
It depends how you define the week number, some years have 52 weeks, some have 53 and not all countries count them in the same way (http://en.wikipedia.org/wiki/Week_number#Week_number). Here are some scripts that calculate the week number in different ways:



12-08-2008, 02:44 PM
Thanks! I can add an iframe with a custom page (iWeb doesn't want me to tweak the head), and have it show a div with the id matching the week number. Right?

12-10-2008, 12:36 PM
Yeah, I guess so. If you encounter any problems you can always come back here.

12-10-2008, 06:40 PM
It has worked so far, but what I want it to do is show a <div> with the id matching the week number. Firebug tells me that "contentDiv is null". My code is this:

function showContent(){

//Get the week number
var divNumber = getWeek(y2k(now.getYear()),now.getMonth(),now.getDate());

//Specify the container
var contentDiv = document.getElementById(divNumber);

//Show the container

And later in the Body:


I clearly defined contentDiv as you can see, but it simply doesn't work. Any suggestions?