Save the text below as countdown.hta using NotePad. Then double-click on the CountDown.hta file to run it.
You can set the target date and the message by setting D and MSG in the code.
The form is positioned at the top-right of the screen but you can change that in the SetPos routine.
The CommaFormatted function is not used in this example but may be useful if you just want something like 'seconds before Christmas' as one big number.
Works under XP but there seems to be a problem under Win7 with the gradient fill when using an hta!
<head>
<title>CountDown</title>
<HTA:APPLICATION
APPLICATIONNAME="Green RM"
MAXIMIZEBUTTON="no"
MINIMIZEBUTTON="no"
BORDER="thick"
SCROLL="no"
SINGLEINSTANCE="yes"
BORDERSTYLE="Static"
ICON="Green.bmp"
>
</head>
<script language="JavaScript">
<!--
// SET YOUR TARGET DATE HERE!
D = new Date("25 Dec 2013 UTC");
// SET YOUR MESSAGE HERE!
MSG = "Time remaining";
var MS_IN_A_DAY = 1000*60*60*24;
var MS_IN_AN_HOUR = 1000*60*60;
var MS_IN_A_MINUTE = 1000*60;
var MS_IN_A_SECOND = 1000;
today = new Date();
// Get msec from each, and subtract.
diff = today.getTime() - D.getTime();
function CommaFormatted(amount)
{
var delimiter = ",";
var i = parseInt(amount);
if(isNaN(i)) { return ''; }
var minus = '';
if(i < 0) { minus = '-'; }
i = Math.abs(i);
var n = new String(i);
var a = [];
while(n.length > 3)
{
var nn = n.substr(n.length-3);
a.unshift(nn);
n = n.substr(0,n.length-3);
}
if(n.length > 0) { a.unshift(n); }
n = a.join(delimiter);
amount = n;
amount = minus + amount;
return amount;
}
// end of function CommaFormatted()
function update() {
// D = new Date("20 Oct 2008 UTC");
today = new Date();
// Get msec from each, and subtract.
diff = D.getTime() - today.getTime() ;
var numDays = diff/MS_IN_A_DAY;
diff = diff%MS_IN_A_DAY;
var numHours = diff/MS_IN_AN_HOUR;
diff = diff%MS_IN_AN_HOUR;
var numMinutes = diff/MS_IN_A_MINUTE;
diff = diff%MS_IN_A_MINUTE;
var numSeconds = diff/MS_IN_A_SECOND;
sdays = Math.round(numDays) + " days ";
shours = Math.round(numHours) + " hrs "
smins = Math.round(numMinutes) + " mins "
ssecs = Math.round(numSeconds) + " secs"
result = sdays + shours + ssecs ;
result = "<p align=center>" + result + "</p>"
mt = "<p align=center>" + MSG + "</p>"
document.getElementById("cnt").innerHTML = mt + result ;
ID=window.setTimeout("update();",1000);
self.focus()
}
// -->
</script>
<script language="VBScript">
MyWidth=560
MyHeight=220
Sub Window_onLoad
window.resizeTo MyWidth,MyHeight
SetPos()
End Sub
Sub SetPos
window.moveTo screen.width - MyWidth, -30
End Sub
</script>
<body onBlur="self.focus()" onload="update()"
STYLE="font:34 pt arial;
color:red; background-color: green;
filter:progid:DXImageTransform.Microsoft.Gradient
(GradientType=1,
StartColorStr='#000000',
EndColorStr='#00FF00')">
<b>
<div name=cnt id=cnt></div>
</b>
</body>