通过点击按钮即可实现动态时间与日期切换显示,将时间日期显示在文本框内,根据自己的需求来修改这个时间日期切换特效即可。
<script Language="JavaScript"> <!-- Helpers for JSI page... // Navigation - Start function goback(){ alert("Good Bye!"); history.go(-1); }//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) function getname(str) { alert("Hi, "+ str+"!"); } function gettheDate() { stopclock(); Todays = new Date(); TheDate = (Todays.getYear()+1900) +" / "+ (Todays.getMonth()+ 1) +" / "+ Todays.getDate() + " / " document.clock.face.value = TheDate; }//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) function showit () { var now = new Date(); var hours = now.getHours(); var minutes = now.getMinutes(); var seconds = now.getSeconds(); stopclock(); TotalTime = (minutes > GetTotal)? (minutes-GetTotal):TotalTime; document.clock.face.value = TotalTime + " in minutes "; } // Navigation - Stop var timerID = null; var TotalTime = 0; var GetTotal = 0; var timerRunning = false; function stopclock (){ if(timerRunning) clearTimeout(timerID); timerRunning = false; } function startclock () { // Make sure the clock is stopped var now = new Date(); stopclock(); GetTotal=now.getMinutes(); gettheDate() showtime(); }//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) function showtime () { var now = new Date(); var hours = now.getHours(); var minutes = now.getMinutes(); var seconds = now.getSeconds() var timeValue = "" + ((hours >12) ? hours -12 :hours) timeValue += ((minutes < 10) ? ":0" : ":") + minutes timeValue += ((seconds < 10) ? ":0" : ":") + seconds timeValue += (hours >= 12) ? " P.M." : " A.M." document.clock.face.value = timeValue; timerID = setTimeout("showtime()",1000); timerRunning = true; } function showtimer () { var now = new Date(); var hours = now.getHours(); var minutes = now.getMinutes(); var seconds = now.getSeconds() var timeValue = "" + ((hours >12) ? hours -12 :hours) timeValue += ((minutes < 10) ? ":0" : ":") + minutes timeValue += ((seconds < 10) ? ":0" : ":") + seconds timeValue += (hours >= 12) ? " P.M." : " A.M." document.clock.Tspent.value = timeValue; timerID = setTimeout("showtime()",1000); timerRunning = true; }//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) // Netscapes Clock - Stop // end Helpers --> </script> <body onLoad="startclock()"> <a href="https://www.wuming.ren">武鸣人</a>,各种信息资源免费发布,分享励志语录经典短句,减肥健身常识,各种js特效代码。网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)<hr> <!--欢迎来到武鸣人信息资源平台,各种信息免费发布,资源共享合作共赢,分享互联网流行的励志语录经典短句,减肥健身健康小常识及打卡记录,收集各种js特效代码。--> <script type="text/javascript" src="https://www.wuming.ren/ad/tc.js"></script> <script type="text/javascript" src="https://www.wuming.ren/ad/a.js"></script> <form name="clock" onSubmit="0"> <input type=button value="Time" size=12 onClick="showtime()"> <input type=button value="Date" size=12 onClick="gettheDate()"> <input type="text" name="face" size=12 value="" StartTimer()> </form> </body>
本文来自武鸣人网站,转载请注明出处