电脑爱好者,提供IT资讯信息及各类编程知识文章介绍,欢迎大家来本站学习电脑知识。 最近更新 | 联系我们 RSS订阅本站最新文章
电脑爱好者
站内搜索: 
当前位置:首页>> Javascript>>JavaScript日期大全-文本框里的时钟:

JavaScript日期大全-文本框里的时钟

来源:远方网络 | 2005-7-16 10:34:01 | (有2346人读过)

<script LANGUAGE="JavaScript">
<!-- Begin
day = new Date();
miVisit = day.getTime();
function clock() {
today = new Date();
hrNow = today.getHours();
mnNow = today.getMinutes();
scNow = today.getSeconds();
miNow = today.getTime();
if (hrNow == 0) {
hour = 12;
ap = "A";
} else if(hrNow <= 11) {
ap = "A";
hour = hrNow;
} else if(hrNow == 12) {
ap = "P";
hour = 12;
} else if (hrNow >= 13) {
hour = (hrNow - 12);
ap = "P";
}
if (hrNow >= 13) {
hour = hrNow - 12;
}
if (mnNow <= 9) {
min = "0" + mnNow;
}
else (min = mnNow)
if (scNow <= 9) {
secs = "0" + scNow;
} else {
secs = scNow;
}
time = hour + ":" + min + ":" + secs + ap;
document.form.button.value = time;
setTimeout(''clock()'', 1000);
}
function timeInfo() {
milliSince = miNow;
milliNow = miNow - miVisit;
secsVisit = Math.round(milliNow / 1000);
minsVisit = (milliNow / 1000) / 60;
alert("给你提个醒: "
+ "你已经在本页面上停留了大约" + minsVisit + "分或"
+ secsVisit + "秒");
}
document.write("<left><form name=\"form\">"
+ "<input type=button value=\"Click for info!\""
+ " name=button onClick=\"timeInfo()\"></form></left>");
onError = null;
clock();
// End -->
</script>
Javascript热门文章排行
网站赞助商
购买此位置

 

关于我们 | 网站地图 | 文档一览 | 友情链接| 联系我们

Copyright © 2003-2024 电脑爱好者 版权所有 备案号:鲁ICP备09059398号