JavaScript Countdown Function

This morning (Thursday, February 18, 2004) Bob Harris on the This Modern World blog noted, with some glee, the dwindling number of days that the current resident of the White House has left in office, assuming the liberals and Democrats (not necessarily the same people) get their way. He noted that a savvy Javascript coder could come up with a code snippet that could be inserted on a page, counting down the days. As I write this, he had gotten over 60 responses so far.

Well, since I was already about done by the time I saw that update, I figured I'd go ahead and post mine too. There will be much spiffier ones, but I think mine has some advantage in terms of brevity, simplicity, and re-usability. It does not use any graphics, but does enable CSS styles to be easily applied. The disadvantages are it calculates only days, and (as used here) does not update itself continously. (Since it only shows days, this is only a problem if you keep the page open over midnight.)

Here it the code which prints the the text below it, in its entirety (except for the CSS style definitions):


Comments