Wednesday, May 31, 2006

Stupid Web Tricks: Automatic content refresh

You've fought a mighty battle to keep your site fresh with ever changing content and the latest bells and whistles. Now you're tired and afraid that your fatigue is starting to show. So why not avail yourself of the tricks used by the demimonde for centuries? There's nothing a little careful lighting, some flattering colors, and the element of surprise won't do to make even the most shop-worn goods look appealing. All you have to do is engage in a little trickery by having your page elements change with the tides using a little JavaScript code. Let your much-needed vacation begin!

Paste this code into the of your Web page:



Now you have two variables, theDay and theHour, that hold the reader's day of the week (as a number from 0 to 6, starting from Sunday) and hour of the day (from 0 to 23). You will use these variables in scripts (placed in the of your page) that will dynamically write parts of your page. You can easily preview your own time- or date-based pages by temporarily resetting your computer's clock.

If it's ecru, it must be Tuesday
For example, for a custom color scheme based on the day of the week, replace your opening tag with a script such as this:



Or perhaps you'd like a daily image with an optional message:



Touch me in the morning, when I am blanchedalmond
Maybe your audience is unusually perceptive, or maybe you just want to up the tempo. Use a similar script based on theHour to make the appearance change as many times a day as you like--every hour if that's what it takes. Here's an example where we assume that people crave newness from you about four times a day; you could change it to smaller increments by adding new if clauses:



You can see how the endless variety afforded by two or more such scripts might relieve some of your viewer fatigue stress. Just be sure the possible combinations coordinate nicely. Then go directly to the airport and bring small bills for the nice stewardess.

No comments: