script05.js

来自「图灵程序设计丛书 JavaScript基础教程源代码」· JavaScript 代码 · 共 25 行

JS
25
字号
window.onload = showTheTime;function showTheTime() {	var now = new Date();	document.getElementById("showTime").innerHTML = showTheHours(now.getHours()) + showZeroFilled(now.getMinutes()) + showZeroFilled(now.getSeconds()) + showAmPm();	setTimeout("showTheTime()",1000);		function showTheHours(theHour) {		return (showMilitaryTime() || (theHour > 0 && theHour < 13)) ? theHour : (theHour == 0) ? 12 : theHour-12;	}		function showZeroFilled(inValue) {		return (inValue > 9) ? ":" + inValue : ":0" + inValue;	}	function showMilitaryTime() {		return (document.getElementById("showMilitary").checked);	}		function showAmPm() {		return (showMilitaryTime()) ? "" : (now.getHours() < 12) ? " AM" : " PM";	}}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?