input获取当前时间

作者在 2007-03-06 21:37:00 发布以下内容

<style type="text/css">
body {
 background-color: transparent;
 margin:0px;
}
.m_frameborder {
 border-left: 1px inset #D4D0C8;
 border-top: 1px inset #D4D0C8;
 border-right: 1px inset #FFFFFF;
 border-bottom: 1px inset #FFFFFF;
 width: 70px;
 height: 19px;
 background-color: transparent;
 overflow: hidden;
 text-align: right;
 font-family: "Tahoma";
 font-size: 10px;
}
.m_arrow {
 width: 16px;
 height: 8px;
 font-family: "Webdings";
 font-size: 7px;
 line-height: 2px;
 padding-left: 2px;
 cursor: default;
}
.m_input {
 width: 18px;
 height: 14px;
 border: 0px solid black;
 font-family: "Tahoma";
 font-size: 9px;
 text-align: right;
}
input{
 background-color:transparent;
}
</style>

<script language="javascript">
// Written by cloudchen, 2004/03/15
function minute(name,fName) {
 this.name = name;
 this.fName = fName || "m_input";
 this.timer = null;
 this.fObj = null;
 
 this.toString = function() {
  var objDate = new Date();
  var sMinute_Common = "class=\"m_input\" maxlength=\"2\" name=\""+this.fName+"\" onfocus=\""+this.name+".setFocusObj(this)\" onblur=\""+this.name+".setTime(this)\" onkeyup=\""+this.name+".prevent(this)\" onkeypress=\"if (!/[0-9]/.test(String.fromCharCode(event.keyCode)))event.keyCode=0\" onpaste=\"return false\" ondragenter=\"return false\" style=\"ime-mode:disabled\"";
  var sButton_Common = "class=\"m_arrow\" onfocus=\"this.blur()\" onmouseup=\""+this.name+".controlTime()\" disabled"
  var str = "";
  str += "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
  str += "<tr>"
  str += "<td>"
  str += "<div class=\"m_frameborder\">"
  str += "<input radix=\"24\" value=\""+this.formatTime(objDate.getHours())+"\" "+sMinute_Common+">:"
  str += "<input radix=\"60\" value=\""+this.formatTime(objDate.getMinutes())+"\" "+sMinute_Common+">:"
  str += "<input radix=\"60\" value=\""+this.formatTime(objDate.getSeconds())+"\" "+sMinute_Common+">"
  str += "</div>"
  str += "</td>"
  str += "<td>"
  str += "<table border=\"0\" cellspacing=\"2\" cellpadding=\"0\">"
  str += "<tr><td><button id=\""+this.fName+"_up\" "+sButton_Common+">5</button></td></tr>"
  str += "<tr><td><button id=\""+this.fName+"_down\" "+sButton_Common+">6</button></td></tr>"
  str += "</table>"
  str += "</td>"
  str += "</tr>"
  str += "</table>"
  return str;
 }
 this.play = function() {
  this.timer = setInterval(this.name+".playback()",1000);
 }
 this.formatTime = function(sTime) {
  sTime = ("0"+sTime);
  return sTime.substr(sTime.length-2);
 }
 this.playback = function() {
  var objDate = new Date();
  var arrDate = [objDate.getHours(),objDate.getMinutes(),objDate.getSeconds()];
  var objMinute = document.getElementsByName(this.fName);
  for (var i=0;i<objMinute.length;i++) {
   objMinute.value = this.formatTime(arrDate)
  }
 }
 this.prevent = function(obj) {
  clearInterval(this.timer);
  this.setFocusObj(obj);
  var value = parseInt(obj.value,10);
  var radix = parseInt(obj.radix,10)-1;
  if (obj.value>radix||obj.value<0) {
   obj.value = obj.value.substr(0,1);
 &nbs

技术随笔 | 阅读 2258 次
文章评论,共0条
游客请输入验证码