OK. Here's a script with a countdown timer, I don't know if it's what you wanted, and my other script's better, but here you go:
Code:
<html>
<head>
<script type="text/javascript">
//Change these
var intervalT = 5000; //Time in milliseconds untill refresh
var intervalR = 10; //Time in milliseconds untill timer update
//WARNING intervalR: A NUMBER TOO SMALL CAN CAUSE LAG, AND TEREFORE CAUSE THE TIMER TO GO SLOWER THAN REAL TIME
var displayF = .001; //Amount that the time in milliseconds should be multiplied by before displaying
var displayP = 3; //Number of decimal places to be displayed
var displayS = " seconds"; //String to be inserted after display
var displayId = "displ"; //ID of display element
var elementId = "myBox"; //ID of text box
//Don't change this crap
var disp;
var ele;
var go = true;
var time = intervalT;
var inter = intervalT;
var toDecimalP = function (num) {
var fac = Math.pow (10,displayP);
var temp = Math.round (fac * num);
return temp / fac;
};
window.onload = function () {
disp = document.getElementById (displayId);
ele = document.getElementById (elementId);
var inter = setInterval (function () {
if (go) {
time -= intervalR;
if (time <= 0) {
location.reload ();
}
}
if (disp.hasChildNodes ()) {
disp.removeChild (disp.firstChild);
}
disp.appendChild (document.createTextNode (toDecimalP (time * displayF) + displayS));
},intervalR);
ele.onkeydown = function () {
setTimeout (function () {
if (ele.value == "") {
go = true;
}
else {
go = false;
}
},0);
};
};
</script>
</head>
<body>
<input type="text" id="myBox" />
<div id="displ"></div>
</body>
</html>
Stephen
Bookmarks