用JavaScript 及HTML语言编写代码。能够在网页上动态显示系统当前的年、月、日、小时、分钟、秒
1个回答
展开全部
这个百度很多的,好不.....
<script><!--
var
ns4up1
=
(document.layers)
?
1
:
0;
//
browser
sniffer
var
ie4up1
=
(document.all&&(navigator.appVersion.indexOf("MSIE
4")
==
-1))
?
1
:
0;
var
ns6up1
=
(document.getElementById&&!document.all)
?
1
:
0;
function
nowclock()
{
if
(!ns4up1
&&
!ie4up1
&&
!ns6up1)
return
false;
var
digital
=
new
Date();
var
hours
=
digital.getHours();
var
minutes
=
digital.getMinutes();
var
seconds
=
digital.getSeconds();
var
day
=
digital.getDate();
var
month
=
digital.getMonth()
+
1;
var
year
=
digital.getYear();
var
amOrPm
=
"上午";
if
(hours
>
11)
amOrPm
=
"下午";
if
(hours
>
12)
hours
=
hours
-
12;
if
(hours
==
0)
hours
=
12;
if
(minutes
<
10)
minutes
=
"0"
+
minutes;
if
(seconds
<
10)
seconds
=
"0"
+
seconds;
if
(day
<
10)
day
=
"0"
+
day;
if
(month
<
10)
month
=
"0"
+
month;
dispTime
=
amOrPm+"
"+hours
+
":"
+
minutes
+
":"
+
seconds
;
dispDate
=
year
+
"年"
+
month
+
"月"
+
day+
"日
"
;
if
(ns4up1)
{
document.layers.nowTime.document.write(dispTime);
document.layers.nowTime.document.close();
document.layers.nowDate.document.write(dispDate);
document.layers.nowDate.document.close();
}
else
if
(ns6up1){
document.getElementById("nowTime").innerHTML
=
dispTime;
document.getElementById("nowDate").innerHTML
=
dispDate;
}
else
if
(ie4up1){
nowTime.innerHTML
=
dispTime;
nowDate.innerHTML
=
dispDate;
}
setTimeout("nowclock()",
1000);
}
nowclock();
//-->
</script>
<script><!--
var
ns4up1
=
(document.layers)
?
1
:
0;
//
browser
sniffer
var
ie4up1
=
(document.all&&(navigator.appVersion.indexOf("MSIE
4")
==
-1))
?
1
:
0;
var
ns6up1
=
(document.getElementById&&!document.all)
?
1
:
0;
function
nowclock()
{
if
(!ns4up1
&&
!ie4up1
&&
!ns6up1)
return
false;
var
digital
=
new
Date();
var
hours
=
digital.getHours();
var
minutes
=
digital.getMinutes();
var
seconds
=
digital.getSeconds();
var
day
=
digital.getDate();
var
month
=
digital.getMonth()
+
1;
var
year
=
digital.getYear();
var
amOrPm
=
"上午";
if
(hours
>
11)
amOrPm
=
"下午";
if
(hours
>
12)
hours
=
hours
-
12;
if
(hours
==
0)
hours
=
12;
if
(minutes
<
10)
minutes
=
"0"
+
minutes;
if
(seconds
<
10)
seconds
=
"0"
+
seconds;
if
(day
<
10)
day
=
"0"
+
day;
if
(month
<
10)
month
=
"0"
+
month;
dispTime
=
amOrPm+"
"+hours
+
":"
+
minutes
+
":"
+
seconds
;
dispDate
=
year
+
"年"
+
month
+
"月"
+
day+
"日
"
;
if
(ns4up1)
{
document.layers.nowTime.document.write(dispTime);
document.layers.nowTime.document.close();
document.layers.nowDate.document.write(dispDate);
document.layers.nowDate.document.close();
}
else
if
(ns6up1){
document.getElementById("nowTime").innerHTML
=
dispTime;
document.getElementById("nowDate").innerHTML
=
dispDate;
}
else
if
(ie4up1){
nowTime.innerHTML
=
dispTime;
nowDate.innerHTML
=
dispDate;
}
setTimeout("nowclock()",
1000);
}
nowclock();
//-->
</script>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询