| 项目搜索 |
| |
|
代码片段库:
查看代码片段
浏览
| 提交新的代码片段
| 创建代码包
全日制时钟
|
类型:
Full Script |
类别:
HTML Manipulation
|
许可证:
GNU General Public License |
语言:
JavaScript
|
描述:
一个全日制的时钟,可以选择显示的方式
|
该代码片段的版本系列:
片段ID |
下载版本 |
提交时间 |
提交人 |
删除 |
4723 | 1.0 | 2003-10-14 16:44 | cbd001 | |
点击"下载版本"来下载该代码片段.
最新版本的代码片段: 1.0
脚本说明:
第一步:把如下代码加入<body>区域中:
<script language="JavaScript">
function showMilitaryTime()
{
if (document.form.showMilitary[0].checked)
{
return true;
}
return false;
}
function showTheHours(theHour)
{
if (showMilitaryTime() || (theHour > 0 && theHour < 13))
{
if (theHour == "0") theHour = 12;
return (theHour);
}
if (theHour == 0)
{
return (12);
}
return (theHour-12);
}
function showZeroFilled(inValue)
{
if (inValue > 9)
{
return "" + inValue;
}
return "0" + inValue;
}
function showAmPm()
{
if (showMilitaryTime())
{
return ("");
}
if (now.getHours() < 12)
{
return (" am");
}
return (" pm");
}
function showTheTime()
{
now = new Date
document.form.showTime.value = showTheHours(now.getHours()) + ":" + showZeroFilled(now.getMinutes()) + ":" + showZeroFilled(now.getSeconds()) + showAmPm()
setTimeout("showTheTime()",1000)
}
</script>
<FORM name=form><INPUT name=showTime size=11>
<P><INPUT CHECKED name=showMilitary type=radio>Military Time<BR><INPUT
name=showMilitary type=radio Unchecked> 12 Hour Time </FORM>
第二步:把<body>区域中的内容改为:
<body bgcolor="#fef4d9" onload=showTheTime()>
如果您修改了一个代码片段并且觉得很应该让别人共享,您可以把这作为这个代码片段的最新版本提交上来. |
|