49、状态栏和标题栏显示时间

49、状态栏和标题栏显示时间

脚本说明:

第一步:把如下代码加入<body>区域中

<SCRIPT LANGUAGE="JavaScript">

function clock() {

var title="现在时间为:";

var date=new Date();

var year=date.getYear();

var month=date.getMonth();

var day=date.getDate();

var hour=date.getHours();

var minute=date.getMinutes();

var second=date.getSeconds();

var months=new Array("JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC")

 

var monthname=months[month];

 

if (hour > 12) {

hour=hour- 12;

}

 

if (minute < 10) {

minute="0"+minute;

}

 

if (second < 10) {

second="0"+second;

}

 

 

document.title=title+" "+monthname+" "+day+", "+year+" - "+hour+":"+minute+":"+second;

status=title+" "+monthname+" "+day+", "+year+" - "+hour+":"+minute+":"+second;

 

setTimeout("clock()", 1000)

 

}

</script>

 

 

      

第二步:把<body>中的代码改为:

<BODY onLoad="clock()">

Write a comment

Comments: 0