82、在标题栏显示时间

82、在标题栏显示时间

要完成此效果把如下代码加入到<body>区域中

 

<SCRIPT LANGUAGE="JavaScript">

 

 

 

 

 

 

<!-- Begin

 

var clocktext;

 

var pagetitle = document.title;

 

function scroll() {

 

today = new Date();

 

sec = today.getSeconds();

 

hr = today.getHours();

 

min = today.getMinutes();

 

if (hr <= 9) hr = "0" + hr;

 

if (min <= 9) min = "0" + min;

 

if (sec <= 9) sec = "0" + sec;

 

var clocktext = " 现在时间是: " + hr + ":" + min + ":" + sec;

 

clocktimer = setTimeout("scroll()", 1000);

 

document.title = pagetitle + clocktext;

 

}

 

if (document.all) scroll();

 

//  End -->

 

</script>

 

Write a comment

Comments: 0