E-Mail:
Author Avatar

JavaScript: How do I change my Web page based on time of day?

Dave, I need your help. I’m updating my Web site for The David Lawrence Show and would like to display ‘ON THE AIR’ between 7p and 10p PT (3a to 6a GMT) Monday through Saturday, and ‘OFF THE AIR’ the rest of the time. I can easily replace this displayed text with an image tag once I find an on-air light graphic that doesn’t look like it’s from 1943. How do I do this?

This is a classic situation where you could use a number of different paths to attain the same goal, ranging from a CGI solution to a small server-side include, to a PHP script or, the solution I’ll demonstrate here, a JavaScript client-side snippet.

Each has its strengths and weaknesses, and for JavaScript the risk is that some percentage of your viewers will probably have JavaScript disabled in their browsers. Assuming you can live with only about 95% of your visitors knowing if you’re on the air at that moment, this should work reasonably well, and it’s really easy to add without making any changes on the server.

There’s one other potential hiccup in that since JavaScript is client-side…

Continue reading about JavaScript, Date Objects and HTML   (help desk)

What Do You Think?

 


Anti-Spam Image

Want to Start a Blog Here for Free?

Are you an expert in one subject or another? If your goal is to help others and dispense hard-earned information back to the community, stake a claim on your very own Lockergnome blog today! You can write about anything - no matter the topic. Sign-up to start blogging!

Author Avatar
Flash, SEO - Aug 6, 2008

Flash And SEO: Like Oil And Water

56 queries / 0.339 seconds.