<html>
<head>
<title>look the status change</title>
</head>
<body>
<script type="text/javascript">
var nowtime ;
var year ;
var month ,date,hours,minutes,seconds,all;
function aaa()
{
nowtime = new Date();
year = nowtime.getYear();
month = nowtime.getMonth()+1;
date = nowtime.getDate();
hours = nowtime.getHours();
minutes = nowtime.getMinutes();
seconds = nowtime.getSeconds();
all = year + " "+month +" "+ date +" "+ hours +":"+minutes+":"+seconds;
document.form.text.value=all;
window.setTimeout("aaa();",1000);
}
aaa();
</script>
</body>
</html>
一直报错 不清楚错在哪里 请高手指教
<head>
<title>look the status change</title>
</head>
<body>
<script type="text/javascript">
var nowtime ;
var year ;
var month ,date,hours,minutes,seconds,all;
function aaa()
{
nowtime = new Date();
year = nowtime.getYear();
month = nowtime.getMonth()+1;
date = nowtime.getDate();
hours = nowtime.getHours();
minutes = nowtime.getMinutes();
seconds = nowtime.getSeconds();
all = year + " "+month +" "+ date +" "+ hours +":"+minutes+":"+seconds;
document.form.text.value=all;
window.setTimeout("aaa();",1000);
}
aaa();
</script>
</body>
</html>
一直报错 不清楚错在哪里 请高手指教
没text这个对象嘛你
<head>
<title>look the status change</title>
</head>
<body>
<input type="text" name="text" id="text" />
<script type="text/javascript">
var nowtime ;
var year ;
var month ,date,hours,minutes,seconds,all;
function aaa()
{
nowtime = new Date();
year = nowtime.getYear();
month = nowtime.getMonth()+1;
date = nowtime.getDate();
hours = nowtime.getHours();
minutes = nowtime.getMinutes();
seconds = nowtime.getSeconds();
all = year + " "+month +" "+ date +" "+ hours +":"+minutes+":"+seconds;
document.getElementById("text").value=all;
window.setTimeout("aaa();",1000);
}
aaa();
</script>
</body>
</html>
<head>
<title>look the status change</title>
<script type="text/javascript">
var nowtime ;
var year ;
var month ,date,hours,minutes,seconds,all;
function aaa()
{
nowtime = new Date();
year = nowtime.getYear();
month = nowtime.getMonth()+1;
date = nowtime.getDate();
hours = nowtime.getHours();
minutes = nowtime.getMinutes();
seconds = nowtime.getSeconds();
all = year + " "+month +" "+ date +" "+ hours +":"+minutes+":"+seconds;
document.myform.text.value=all;
//document.getElementById("txt").value = all;
window.setTimeout("aaa();",1000);
}</script>
</head>
<body onLoad = "aaa()">
<form name = "myform"><div><input type = "text" id = "txt" name = "text"></div>
</form>
</body>
</html>
在Firefox等浏览器内getYear返回的是 “当前年份减去1900”的值(即年份基数是1900)
<head>
<title>look the status change</title>
</head>
<body>
<script type="text/javascript">
var nowtime ;
var year ;
var month ,date,hours,minutes,seconds,all;
function aaa()
{
nowtime = new Date();
year = nowtime.getYear();
month = nowtime.getMonth()+1;
date = nowtime.getDate();
hours = nowtime.getHours();
minutes = nowtime.getMinutes();
seconds = nowtime.getSeconds();
all = year + " "+month +" "+ date +" "+ hours +":"+minutes+":"+seconds;
document.write(all);
window.setTimeout("aaa();",1000);
}
aaa();
</script>
</body>
</html>
再问一个问题 我写成document.write(all) 为什么 时间就跳两次 就报错了 很不理解 谢谢
是不是 在时钟这样的问题上是不能用 document.write()的????
document.write()会默认调用document.open()打开一个新文档。
你的时钟在页面没有加载完成就执行了,所以第一次document.write()会在本页上显示。当第二次时就会打开一个新的文档,你的脚本也就被覆盖掉了,不能执行了。