飞-超
飞-超

★JavaScript实现按钮显示本地时间/点击显示网页停留的时间★

JavaScript实现一款网页时间特效,在按钮上显示网页时间,点击按钮后可显示你在该网页上停留的时间,以分钟来计。转自网页代码站

<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("欢迎光临记忆时光|二超博客

" //

用来换行
+ "你已经在本页面上停留了大约" + minsVisit + "分"+ secsVisit + "秒"+ " ");
}
document.write("<center><form name="form">"
+ "<input type=button value="Click for info!""
+ " name=button onClick="timeInfo()"></form></center>");
onError = null;
clock();
// End -->
</script>

#
首页      源码分享      ★JavaScript实现按钮显示本地时间/点击显示网页停留的时间★

5258

文章作者

发表评论

textsms
account_circle
email

飞-超

★JavaScript实现按钮显示本地时间/点击显示网页停留的时间★
JavaScript实现一款网页时间特效,在按钮上显示网页时间,点击按钮后可显示你在该网页上停留的时间,以分钟来计。转自网页代码站 <script language="JavaScript"> <!-- Begin da…
扫描二维码继续阅读
2014-08-21