Nothing is for sale here. Freewill tips keep the site running. Want to help? → Tip via Paypal

Daily Content Rotator

This JavaScript will allow you to have a tip of the day, a daily quote, poem a day, daily YouTube video, or other "things" of the day on your web page. There are several more ideas listed at the end.

First an example, then the script, and then the things you have to know to make it work. Don’t worry, it’s easy. Here’s an example using the script as a kind of digital fortune cookie: .

fortune cookie Your Fortune:

You’ll see a different fortune if you come back here tomorrow.

This script does require the user to have JavaScript enabled, but most people do. If not, they’ll see whatever content you place between the no script tags at the end.

Here’s the code for that script:

<script>
//Courtesy of BoogieJack.com
var msg = new Array();
insert = new Date();
today = insert.getDate();
msg[0]="Tip 1 text here."
msg[1]="Tip 2 text here."
msg[2]="Tip 3"
msg[3]="Tip 4"
msg[4]="Tip 5"
msg[5]="Tip 6"
msg[6]="Tip 7"
msg[7]="Tip 8"
msg[8]="Tip 9"
msg[9]="Tip 10"
msg[10]="Tip 11"
msg[11]="Tip 12"
msg[12]="Tip 13"
msg[13]="Tip 14"
msg[14]="Tip 15"
msg[15]="Tip 16"
msg[16]="Tip 17"
msg[17]="Tip 18"
msg[18]="Tip 19"
msg[19]="Tip 20"
msg[20]="Tip 21"
msg[21]="Tip 22"
msg[22]="Tip 23"
msg[23]="Tip 24"
msg[24]="Tip 25"
msg[25]="Tip 26"
msg[26]="Tip 27"
msg[27]="Tip 28"
msg[28]="Tip 29"
msg[29]="Tip 30"
msg[30]="Tip 31"
document.write(msg[today-1]);
</script>
<noscript>
Your browser cannot display this content because JavaScript is not enabled.
</noscript>

And now, the stuff you need to know…

First, you’ll notice there are 30 messages (msg) and 31 Tips. That’s because the message count starts at zero. That’s the way it is with JavaScript arrays. Tip 1 (msg 0) will display on the first of the month. Tip 2 (msg 1) will display on the second of the month, and so forth. Whoever came with that idea is a genius!

Dress it up however you like. I put the little image of fall leaves and wrote "Your Fortune: " in bold type. There are lots of ways to add sparkle to it. Be creative. The more you put into it the more you'll get out of it.

Place your own tips, quotations, jokes, videos, songs, images or whatever, between the quotation marks where I have Tip 1, Tip 2, all the way through to Tip 31. Here are the requirements regarding the content you place:

Each message must all be on one line of it’s own. It’s OK if it wraps to a second line in your text or HTML editor window, but the messages must not have any hard returns in them or it will break the script.

Avoid using any special characters in your message or you risk breaking the script. If you need to use a special character, preface it with a backslash. That tells the browser to print the character rather than to interpret it.

Examples: You can \”quote me\” on that. I can\’t believe it.

You can use basic text formatting such as bold, italic, paragraph and break tags in the message.

You can include links, so you could also have a site of the day feature or featured page or product on your site. You have to leave off the quotation marks around the web address and target if you use it. Example:

<a href=http://www.boogiejack.com target=_blank>Boogie Jacks</a>

You can embed YouTube videos, but you’ll have to remove all the double quotation marks from the embed code. You can do that in one swell foop if you paste it into Notepad, then go to Edit/Replace and type in a quotation mark into the Find what text box. Leave the Replace with text box blank, and then click the Replace All button and it’s ready to use.

You can paste that entire code into your web page at the place where you want the rotating content and use it like that, or you can paste the Javascript into an external file and link to it. That's what I prefer. To do that:

  1. Remove lines 1 & 2, and lines 38-41 from the code.
  2. Paste the rest into a plain text editor (like Notepad) and save it as a .js file, for example: content-rotator.js
  3. Link to the file at the place in your web page where you want the daily content. Here's how:

    <script src="scripts/content-rotator.js"></script>
    <noscript>
    Your browser cannot display this content because JavaScript is not enabled.
    </noscript>

Be sure to change the path and script name in the example to the actual script name and path to the script you're using. If you don't know about server paths, you'll find this server paths tutorial helpful.

Ideas for this Script

You could use this script for a lot of "daily" things. Here are a few ideas I thought of just to make your life a little easier:
  • daily quote
  • daily tips
  • daily poem
  • daily joke
  • daily video
  • daily image
  • daily site
  • daily horoscope
  • daily recipe
  • daily trivia question
  • daily history note
  • daily feature (product or page on your site)
  • daily book recommendation (think Amazon affiliates!)
  • daily software review (think Clickbank affiliates!)
  • daily person (man, woman, dummy, celebrity, hero, etc.)
  • daily download (link to a software freebie)
  • daily bargain (another affiliate link idea)
  • daily top ten of something
  • daily fortune cookie
  • daily inspiration
  • daily scripture
  • daily freebie
  • daily riddle
…or a big thing of the day, cool thing of the day, question of the day, model of the day, word of the day—honestly, the list of daily possibilities could go on and on.

You could make it a weekly thing instead by simply putting the same thing into the script for seven days in a row.

There are a lot of content ideas for you. You could make more than one script and use several ideas. People like sites that are updated frequently. Make your mark! ...or your john. ...or your karen. ...or your fred. ...or your annie. ...or your