<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>背景时钟</title> </head>
<body>
<p id="bgclockshade" style="position:absolute;visibility:visible;font-family:Verdana;color:#FFAAAA;font-size:100px;top:10px;left:152px"> </p> <script type="text/javascript"> function clockDemo(){
//先获得时间
var time=new Date();
var hour=time.getHours(); //时
var minute=time.getMinutes(); //分
var second=time.getSeconds(); //秒 if(eval(hour)<10) hour="0"+hour; //如果不满10
if(eval(minute)<10) minute="0"+minute;
if(eval(second)<10) second="0"+second;
var timeStr=hour+":"+minute+":"+second;
if(eval(hour)==0 && eval(minute)==0 && eval(second)==0) alert("生日快乐!"); var bgclockshade=document.getElementById("bgclockshade"); bgclockshade.innerHTML=timeStr; var timer= setTimeout("clockDemo()",200); //没0.2秒刷新时间 } clockDemo(); //启动入口
</script> </body>
</html>