PDA

View Full Version : Scheduled Content



MoscowModder
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.

-MoscowModder

Snookerman
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:

http://syn.ac/tech/19/get-the-weeknumber-with-javascript/

http://www.irt.org/script/914.htm

MoscowModder
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?

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

MoscowModder
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
contentDiv.style.display='inline';
}


And later in the Body:



<script>showContent();</script>


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