ASP网页中用javascript取得时间
用date()time()可以取得到时间,但是有一点,它们都是表态的,也就是说打开网页是什么时间,它就一直是什么时间,怎么让它一直随系统时间的改变而改变,而不用刷新页面?...
用date() time()可以取得到时间,但是有一点,它们都是表态的,也就是说打开网页是什么时间,它就一直是什么时间,怎么让它一直随系统时间的改变而改变,而不用刷新页面?
我不要它显示在按钮上,显示成一个文本就行了。。可以的话,请注上说明,我是新手,想学习一下。。。 展开
我不要它显示在按钮上,显示成一个文本就行了。。可以的话,请注上说明,我是新手,想学习一下。。。 展开
1个回答
展开全部
给你改成文本框的了
<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 = " AM";
} else if(hrNow <= 11) {
ap = " AM";
hour = hrNow;
} else if(hrNow == 12) {
ap = " PM";
hour = 12;
} else if (hrNow >= 13) {
hour = (hrNow - 12);
ap = " PM";
}
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;
self.status = time;
setTimeout('clock()', 1000);
}
function timeInfo() {
milliSince = miNow;
milliNow = miNow - miVisit;
secsVisit = Math.round(milliNow / 1000);
minsVisit = Math.round((milliNow / 1000) / 60);
alert("阿捷的<<网页设计室>>自1998年5月28日建立。 "
+ "你已经停留了大约" + minsVisit + "分 "
+ secsVisit + "秒"+ " 在本页面上");
}
document.write("<center><form name=\"form\">"
+ "<input type=txt value=\"Click for info!\""
+ " name=button></form></center>");
onError = null;
clock();
// End -->
</script>
<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 = " AM";
} else if(hrNow <= 11) {
ap = " AM";
hour = hrNow;
} else if(hrNow == 12) {
ap = " PM";
hour = 12;
} else if (hrNow >= 13) {
hour = (hrNow - 12);
ap = " PM";
}
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;
self.status = time;
setTimeout('clock()', 1000);
}
function timeInfo() {
milliSince = miNow;
milliNow = miNow - miVisit;
secsVisit = Math.round(milliNow / 1000);
minsVisit = Math.round((milliNow / 1000) / 60);
alert("阿捷的<<网页设计室>>自1998年5月28日建立。 "
+ "你已经停留了大约" + minsVisit + "分 "
+ secsVisit + "秒"+ " 在本页面上");
}
document.write("<center><form name=\"form\">"
+ "<input type=txt value=\"Click for info!\""
+ " name=button></form></center>");
onError = null;
clock();
// End -->
</script>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询