JavaScript中的数字时钟的显示问题
来源:百度知道 编辑:UC知道 时间:2024/09/12 22:58:47
<html>
<head>
<script language="JavaScript">
function showTime()
{
var currentDate = new Date();
var hours = currentDate.getHours();
var minutes = currentDate.getMinutes();
var seconds = currentDate.getSeconds();
//
//格式化输出
//
if (minutes < 10)
minutes = "0" + minutes;
if (seconds < 10)
seconds = "0" + seconds;
var currentTimeString ="<font color=blue>" + hours + ":" + minutes + ":" + seconds + "</font>";
document.clear();
document.write(currentTimeString);
window.setTimeout("showTime()", 1000);
}
</script>
</head>
<body onload="showTime()">
</body>
</html>.js
保存运行后,只能显示一个静态时钟,网页状态栏显示有错误。我是新手,希望大虾帮忙。
<head>
<script language="JavaScript">
function showTime()
{
var currentDate = new Date();
var hours = currentDate.getHours();
var minutes = currentDate.getMinutes();
var seconds = currentDate.getSeconds();
//
//格式化输出
//
if (minutes < 10)
minutes = "0" + minutes;
if (seconds < 10)
seconds = "0" + seconds;
var currentTimeString ="<font color=blue>" + hours + ":" + minutes + ":" + seconds + "</font>";
document.clear();
document.write(currentTimeString);
window.setTimeout("showTime()", 1000);
}
</script>
</head>
<body onload="showTime()">
</body>
</html>.js
保存运行后,只能显示一个静态时钟,网页状态栏显示有错误。我是新手,希望大虾帮忙。
<html>
<head>
<script language="JavaScript">
function showTime()
{
var currentDate = new Date();
var hours = currentDate.getHours();
var minutes = currentDate.getMinutes();
var seconds = currentDate.getSeconds();
//
//格式化输出
//
if (minutes < 10)
minutes = "0" + minutes;
if (seconds < 10)
seconds = "0" + seconds;
var currentTimeString ="<font color=blue>" + hours + ":" + minutes + ":" + seconds + "</font>";
document.getElementById("show").innerHTML=currentTimeString; //改这地方
window.setTimeout("showTime()", 1000);
}
</script>
</head>
<body onload="showTime()">
<span id="show"></span> <!--加这地方-->
</body>
</html>
//如何在网页