在文本框内显示系统日期,当用户鼠标经过时切换显示系统当前动态时间,移开后又恢复原效果,根据自己网站需求来修改即可。
<SCRIPT LANGUAGE="JavaScript"> <!-- Begin function printDate() {//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) var today = new Date(); var day=today.getDate(); var month = today.getMonth() + 1; var year = today.getFullYear().toString(); var box=document.forms[0].DateBox;//this is where we want to print the date if ( ( month /10 ) < 1 ) { month=("0" + month).toString(); //add the leading 0 -- looks more professional } if ( (day/10)<1) { day=("0" + today.getDate()).toString();//add the leading 0 -- looks better } box.value=month + "-" + day + "-" + year; } function printTime() { var box = document.forms[0].DateBox; //this is where we want to print the date var thetime=new Date(); if (thetime.getMinutes() / 10 <1 ) { box.value=thetime.getHours() + ":" + "0" + thetime.getMinutes(); } else { box.value=thetime.getHours() + ":" + thetime.getMinutes(); } }//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀) // End --> </script> <body onLoad="return printDate()"> <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="stats"> <input type="text" readonly="readonly" name="DateBox" size="10" onmouseover="printTime();" onmouseout="printDate();"> <font size="2">武鸣人提示您:鼠标放上去变成时间显示</font> </input> </form> </body>
本文来自武鸣人网站,转载请注明出处