E
elektrophyte
I've got a short script that works fine in I.E. and Firefox, but not in
Safari. It is supposed to print a constantly-updating counter on the
webpage. Any ideas how to get it to work in Safari? The script uses the
Date object, especially Date.getTime(). Could that have something to do
with the problem?
Thanks,
E
// This <form> is put into the same HTML page as the script...
<form name="counter" style="margin: 0; padding: 0;">
<input type="text" name="amount" value="0" size="40" readonly="true"
style="margin:0;padding:0;border:none;font-size:24px;color:#cc0000;">
</form>
// Here is the script...
<script type="text/javascript">
// The formatNumber function comes from Danny Goodman's JavaScript
Cookbook.
[ ... some code left out here for brevity ... ]
var startingDate = new Date(2005, 0, 1);
var startingDebt = 1000000000;
function updateCounter(){
var nowDate = new Date();
var debtTimeInSeconds = (nowDate.getTime() -
startingDate.getTime())/1000;
var newValue = startingDebt + (debtTimeInSeconds * 3.47);
document.counter.amount.value = "$" + formatNumber(newValue, 2);
}
updateCounter();
intervalID = setInterval("updateCounter()", 1000);
</script>
Safari. It is supposed to print a constantly-updating counter on the
webpage. Any ideas how to get it to work in Safari? The script uses the
Date object, especially Date.getTime(). Could that have something to do
with the problem?
Thanks,
E
// This <form> is put into the same HTML page as the script...
<form name="counter" style="margin: 0; padding: 0;">
<input type="text" name="amount" value="0" size="40" readonly="true"
style="margin:0;padding:0;border:none;font-size:24px;color:#cc0000;">
</form>
// Here is the script...
<script type="text/javascript">
// The formatNumber function comes from Danny Goodman's JavaScript
Cookbook.
[ ... some code left out here for brevity ... ]
var startingDate = new Date(2005, 0, 1);
var startingDebt = 1000000000;
function updateCounter(){
var nowDate = new Date();
var debtTimeInSeconds = (nowDate.getTime() -
startingDate.getTime())/1000;
var newValue = startingDebt + (debtTimeInSeconds * 3.47);
document.counter.amount.value = "$" + formatNumber(newValue, 2);
}
updateCounter();
intervalID = setInterval("updateCounter()", 1000);
</script>