《标题显示时间》 查看源代码

2008-09-25 14:04:00 | 【

在网页的标题栏上显示当前时间,自动走时

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>分享JavaScript-sharejs.com</title>
</head>
<body>

<SCRIPT language=JavaScript> 
var clocktext, timeday; 
var pagetitle = document.title; 
function scroll() { 
today = new Date(); 
sec = today.getSeconds(); 
hr = today.getHours(); 
min = today.getMinutes(); 
if (hr < 12) { timeday = " AM"; } 
else { timeday = " PM"; } 
if (hr > 12) hr = hr - 12; 
if (hr <= 9) hr = "0" + hr; 
if (min <= 9) min = "0" + min; 
if (sec <= 9) sec = "0" + sec; 
var clocktext =  hr + ":" + min + ":" + sec + timeday; 
clocktimer = setTimeout("scroll()", 1000); 
document.title = pagetitle +" 现在时间"+ clocktext; 
} 
if (document.all) scroll(); 
</SCRIPT>
<br><br>
<div align="center">
获取更多JavaScript代码,请登录JavaScript分享网 <a href="http://www.sharejs.com">http://www.sharejs.com</a>
</div>
</body>
</html>

返回 《标题显示时间》