Javascript版時鐘

共享一段 Javascript 版時鐘代碼:


<!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=utf-8" />
<title>Javascript版時鐘</title>
<script>
var oInterval="";
function fnRecycle(){
	var oDate=new Date();
	var sSwitch="AM";//上午
	var iHours=oDate.getHours();
	if(iHours>12){
		iHours-=12;
		sSwitch="PM";//下午
	}
	var sMinutes=oDate.getMinutes() + "";
	if(sMinutes.length==1){
		sMinutes="0" + sMinutes;
	}
	var sSeconds=oDate.getSeconds() + "";
	if(sSeconds.length==1){
		sSeconds="0" + sSeconds;
	}
	oTimer.innerHTML=iHours + ":" + sMinutes + ":" + sSeconds + " " + sSwitch;
}
function window_onload() {
if(oInterval==""){
		oInterval=window.setInterval("fnRecycle()",1000);
	}
}
</script>
</head>

<body  language="javascript" οnlοad="return window_onload()">

<!-- 頁面調用 -->
Javascript版時鐘:<span id="oTimer" ></span>

</body>
</html>


Over!!!


發佈了41 篇原創文章 · 獲贊 6 · 訪問量 33萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章