Este artículo describe la implementación de un selector de fechas que es preciso para segundos por JS. Compártelo para su referencia, como sigue:
<script> // La función de llamada principal es setday (this, [object]) y setday (esto). [Objeto] es la salida del nombre de control por el control. Dé dos ejemplos: // 1. <Input name = txt> <input type = button value = setday onClick = "setday (this, document.all.txt)"> // 2. <Input onfocus = "setday (this)"> var bmovable = true; var strframe; document.writeLn ('<iframe id = enddatelayer frameBorder = 0 width = 162 teart = "style =" POSICIÓN: "POSICIÓN; Z-índice: 9998; sólido; en segundo plano: #63a3e9; font-family: 安安;} '; strframe+=' td {font-size: 9pt; font-family: 安安安;} '; strframe+=' '</style>'; bdrag; '; strframe+=' function document.onmouseMove () '; strframe+=' {if (bdrag && window.event.button == 1) '; strframe+=' {var dataLayer = parent.document.all.enddateLayer.style; '; strframe+=' datElayer.Posleft+= = window.event.clientx-datelayerx; '; strframe+=' dataLayer.postop+= window.event.clienty-datelayery;}} '; strframe+=' function dragStart () '; strframe+=' {var dataLayer = parent.document.all.enddatelayer.style; '; detaLAYERX = WINWAWN.EVENT.CLIENTX; '; strFRame+=' DetaLayery = Window.Event.clienty; '; strframe+=' bdrag = verdadero;} '; style = "Z-Index: 9999; Posición: Absoluto; izquierda: 0; arriba: 0;" onselectstart = "return false"> '; strframe+=' <span id = tmpselectyearlayer style = "z-index: 9999; posición: absoluto; top: 3; izquierda: 19; display: none"> </span> '; strframe+=' <span id = tmpselectmonthlayer style = "Z-Index: 9999; Position: Absolute; Top: 3; 38; 78; Ninguno "> </span> '; strframe+=' <span id = tmpselEctHourlayer style =" Z-Index: 9999; Position: Absolute; Top: 188; 77px; visualización: ninguno "> </span> '; strframe+=' <span id = tmpselectsecondlay style =" Z-Index: 9999; Position: Absolute; Top: 188; borderColor =#63a3e9 bgcolor =#63a3e9> '; strframe+=' <tr> <td width = 142 Height = 23 bgcolor =#ffffff> '; strframe+=' <table border = 0 cellPacing = 1 CellPadding = 0 width = 158 Height = 23> '; <td width = 16 align = Center bgcolor = #63a3e9 style = "font-size: 12px; cursor: hand; color: #ffffff" '; strframe+=' onclick = "parent.meizzprevm ()"> <b> <</b> </td> '; strrfame+=' <td width = 60 align center " bgcolor = "#63a3e9" style = "font-size: 12px; cursor: hand" '; strframe+=' onMouseOver = "style.backgroundcolor =/'#aaccf3/'"; strframe+= 'onmouseout = "style.backgroundcolor =/'#63a3e9/''; onClick = "parent.tmpselectyearInnerHtml (this.inntext.substring (0,4))" '; strframe+='> <span id = meizzyearhead> </span> </td> '; strframe+=' <td width = 48 align = "centro" estilo = "font-tamaño: 12px; font-coro: #ff; #ff; '; strframe+=' bgcolor = "#63a3e9" onMouseOver = "style.backgroundcolor =/'#aaccf3/'"; strframe+= 'onMouseOut = "style.backgroundcolor =/'#63a3e9/" '; strframe+=' onClick = "parent.tmpselectmonThinnerHtml (this.inntext.length == 3? this.inntext.substring (0,1): this.innertext.substring (0,2))" '; strframe+='> <span id = meizzmonthhead> </span> </td>; bgcolor = #63a3e9 align = center style = "font-size: 12px; cursor: hand; color: #ffffff" '; strframe+=' onClick = "parent.meizzNextm ()"> <b>> </b> </td> '; strframe+=' </tr> '; strframe+=' </table> </td> </tr> '; strframe+=' <tr> <td width = 142 height = 18> '; strframe+=' <table border = 0 celularpacing = 0 celular = 2 bgcolor =#63a3e9 '+(bMoVableeable? BorderColorlight =#63a3e9 borderColork =#fffffff width = 140 Height = 20 style = "cursor: ' + (bmovable?' Move ':' default ') +'"> '; strframe + =' <tr> <tr> <td style = "font-size: 12px; color: #ffffff" width = 20> day </td> '; style = "font-size: 12px; color: #ffffff"> one </td> <td style = "font-size: 12px; color: #ffffff"> t </td> '; strframe+=' <td style = "font-size: 12px; color: #ffffff"> one </td> <td <td style = "font-size: 12px; color: #ffffff"> t </td> '; strframe+=' <td style = "font-size: 12px; color: #ffffff"> one </td> <td style = "font-size: 12px; color: #ffffff"> one </td> '; strframe+=' <td style = "font-size: 12px; color: #ffffff"> Six </td> <td style = "font-size: 12px; color: #ffffffff"> Six </td> <td style = "font-size: 12px; color: #ffffff"> Six </td> </tr> '; strrfame+=' <tr> <TD width = 142 tearth > '; strframe+=' <tr> <table border = 1 cellPacing = 2 cellPadding = 2 borderColorlight =#63a3e9 borderColordark =#fffff bgcolor =#fff8ec width = 140 height = 120> '; var n = 0; para (j = 0; j <5; j ++) {strframe+= '<tr align = center>'; para (i = 0; i <7; i ++) {strframe+= '<td width = 20 height = 20 id = meizzday'+n+'style = "font-size: 12px" onclick = parent.meizzdayclick (this.inntext, 0)> </td>'; n ++;} strfame+= '<tr align>'; para (i = 35; i <37; i ++) strframe+= '<td width = 20 height = 20 id = meizzday'+i+'style = "font-size: 12px" onClick = "parent.meizzdayclick (this.inntext, 0)"> </td>'; strframe+= '<td colspan = 5 align onClick = "parent.setNull ()" style = "font-size: 12px; cursor: hand" '; strframe+=' onMouseOver = "style.color =/'#ff0000/'" onMouseOut = "style.color =/'#1478eb/'"> vacío </span> <span oncclick = " style = "font-size: 12px; cursor: hand" '; strframe+=' onMouseOver = "style.color =/'#ff0000/'" onMouseOut = "style.color =/'#1478eb/'"> Current </span> <span span style = "cursor: hand" Id = evaallok onMouseOver = "style.color =///' onmouseout = "style.color =/'#1478eb/'" onClick = "parent.CloSelayer ()"> Close </span> </td> </tr> '; strframe+=' '</table> </td> </tr> bgcolor =#ffffff height = 22> '; strframe+=' <tr bgcolor = "#63a3e9"> <td id = busetImelayer width = 30 style = "cursor: hand"; onMouseOut = "style.backgroundcolor =/'#63a3e9/'"; strframe+= 'onClick = "parent.usetime (this)">'; strframe+= '<span> </span> </td>'; strframe+= '<td style = "cursor: hand" onClick = "parent.tmpselEcthourInnerHtml (this.inntext.length == 3? this.inntext.substring (0,1): this.inntext.substring (0,2))"; strframe+= 'onMouseover = "style.backgroundcolor =/'#aaccf3/'" onMouseOut = "style.backgroundcolor =/'#63a3e9/'"; strframe+= 'align = centro width = 42>'; strframe+= '<span id = meizzhourhead> </span> </td>'; strframe+= '<td style = "cursor: hand" onClick = "parent.tmpselectMinuteInnerhtml (this.inntext.length == 3? this.inntext.substring (0,1): this.innertext.substring (0,2))"; onMouseOut = "style.backgroundcolor =/'#63a3e9/'"; strframe+= 'align = centro width = 42>'; strframe+= '<span id = meizzminutehead> </span> </td>'; strframe+= '<td style = "cursor: hand" onClick = "parent.tmpselectsecondinnerhtml (this.inntext.length == 3? this.inntext.substring (0,1): this.inntext.substring (0,2))"; strframe+= 'onMouseover = "style.backgroundcolor =/'#aaccf3/'" onMouseOut = "style.backgroundcolor =/'#63a3e9/'"; strframe+= 'align = Center width = 42>'; strframe+= '<span id = meizzsecondhead> </span> </td>'; strframe+= ' </tr> </td> </tr> </table> </div> '; window.frames.enddatelayer.document.writeln (strframe); window.frames.enddatelayer.document.close (); // Resolver el problema que la barra de progreso de IE no end//================================================================================================================= ============================================================= ============================================================== Pantalla de la página web Parte ================================================================ ====================================================================== ====================================================================== ====================================================================== ====================================================================== ====================================================================== ====================================================================== ====================================================================== odatelayer = window.enddatelayer.document.all; // odatelayer.buseTimelayer.inntext = "no"; bimgswitch (); odatelayer.buseTimelayer.innerhtml = bimg; function setday (tt, obj) // principal function {if (arguments.lengies> 2) Parámetros pasados a este control! "); return;} if (arguments.length == 0) {alerta (" ¡Lo siento! ¡No revisó ningún parámetro a este control! "); return;} var dads = document.all.enddatelayer.style; var th = tt; var ttop = tt.offsettop; // El punto de posicionamiento del control TT es alto var. // El alto VAR del control TT en sí es tleft = tt.offsetleft; // El punto de posición del control TT es amplio var ttyp = tt.type; // El tipo de control TT es while (tt = tt.offsetparent) {ttop+= tt.offsettop; tleft+= tt.offsetleft;} dads.top = (ttyp == "imagen")? TTOP+thei: ttop+thei+6; dads.left = tleft; outObject = (argumentos.length == 1)? th: obj; outButton = (argumentos.length == 1)? nulo: th; // Establezca el botón externo haciendo clic // Mostrar el año calendario y el mes var reg =/^(/d+)-(/d {1,2})-(/d {1,2})/; // excluyendo el tiempo var r = outObject.Value.match (reg); if (r! = Null) {r [2] = r [2] -1; var d = nueva fecha (r [1], r [2], r [3]); if (d.getblyar () == r [1] && d.getMonth () == r [2] && d.getDate () == r [3]) {Outdate = D; parent.meizztheyear = r [1]; parent.meizzthemonth = r [2]; parent.meizzthedate = r [3]; } else {waskate = ""; } meizzsetday (r [1], r [2] +1);} else {wakeDate = ""; MeizzSetday (new Date (). GetLyEar (), New Date (). GetMonth () + 1);} Dads.display = '' '; // juzga si el tiempo de uso se usa durante la inicialización, verificación no estricter bimgswitch (); odatelayer.busetimelayer.innerhtml = bimg; meizzwritehead (meizztheyear, meizzthemonth); //} // else // {// busetime = false; // bimgswitch (); // odatelayer.busetImelayer.innerhtml = bimg; // meizzwritehead (meizzTheyear, meizzthemonth); //} try {Event.eturg; (e) {// El error se excluye aquí, la causa del error aún no se ha encontrado. }} var monhead = nueva matriz (12); // Definir el número máximo de días por mes en el monte del calendario gregoriano [0] = 31; Monhead [1] = 28; Monhead [2] = 31; Monhead [3] = 30; Monhead [4] = 31; Monhead [5] = 30; Monhead [6] = 31; Monhead [7] = 31; Monhead [8] = 30; Monhead [9] = 31; Monhead [10] = 30; Monhead [11] = 31; var meizztheyear = new Date (). Getfulfyear (); // Defina el valor inicial de la variable del año var meizzthemonth = new Date (). GetMonth ()+1; // Definir el valor inicial de la variable del mes var meizzthedate = new Date (). GetDate (); // Defina el valor inicial de la variable del día var meizztheur = new Date (). Gethours (); // Defina el valor inicial de la variable de hora var meizztheminute = new Date (). GetMinutes (); // Defina el valor inicial de la variable minuto var meizztheseCond = new Date (). GetSeconds (); // Definir el valor inicial de la segunda variable var meizzwday = new Array (37); // matriz que define la fecha de escritura document.onClick = (function () {con (window.event) {if (sricleement! = OutObject && srCelement! = OutButton) ClosElayer ();}}) document.OnKeyUp = (function () {if (window.event.keycode == 27) {if (outObject. outObject.blur (); CloseLayer ();} else if (document.activeElement) {if (document.activeElement! = outObject && document.activeElement! = outButton) {CloseLayer (); "Año"; odatelayer.meizzmonthhead.inntext = format (mm)+"luna"; // inserte la hora y el minuto actual odatelayer.meizzhourhead.inntext = Busetime? (MeizzTheur+"Time"): ""; Odatelayer.MeizzMinutehead.innertext = Busetime minutes"):"";odatelayer.meizzSecondHead.innerText=bUseTime?(meizzTheSecond+" seconds"):"";}function tmpSelectYearInnerHTML(strYear) // drop-down box for year{if (strYear.match(//D/)!=null){alert("The year input parameter is not a número! "); return;} var m = (stryear)? stryear: new Date (). 12px '"s +=" onblur =' document.all.tmpselectyearlayer.style.display =/"none/" '"s +=" onchange =' document.all.tmpselectyearlayer.style.display =/"none/"; "s +=" parent.meizzTheyear = this.value; parent.meizzsetday (parent.meizztheyear, parent.meizzthemonth) '>/r/n "; var selectInnerHtml = s; for (var i = n; i <n + 101; i ++) {if (i == m) {selectInnerHtml + =" <Opción valor = "" + i + "seleccionado>" + i + "año"/"<opción </" <opción </"<option"; } else {selectInnerHtml + = "<option value = '" + i + "'>" + i + "año" + "</option>/r/n"; }} selectInnerHtml += "</select>"; odatelayer.tmpselectyearlayer.style.display = ""; odatelayer.tmpselectyearlayer.innerhtml = selectInnerhtml; odatelayer.tmpselectyear.focus ();} function tmpselectmonThinnerHtml (strmonth) // cuadro desplegable para mes {if (strmonth.match (// d/)! = null) {alert ("¿El parámetro de entrada de mes no es un número!"); return;} var m = (strmonth)? strmonth: nueva fecha (). getMonth () +1; var s = "<select name = tmpselectmonth style = 'font-size: 12px'" s += "onblur = 'document.all.tmpselectmonthlayer.style.display =/" none/"" s += = = " "onchange = 'document.all.tmpselectmonthlayer.style.display =/" none/";" s+= "parent.meizzthemonth = this.value; parent.meizzsetday (parent.meizzTheYear, parent.meizzthemonth)'>/r/n"; var selectInnerhtml = s; para (var i = 1; i <13; == m) {selectInnerHtml+= "<option value = '"+i+"' seleccionado>"+i+"mes"+"</opción>/r/n"; } else {selectInnerHtml+= "<option value = '"+i+"'>"+i+"mes"+"</option>/r/n"; }} selectInnerHtml += "</select>"; odatelayer.tmpSelectMonthlayer.style.display = ""; odatelayer.tmpselectmonthlayer.innerhtml = selectInnerHtml; odateLayer.tmpSelectmonmonTh.focus tmpSelECTTHourInnerHtml (Strhour) // Box de hora desplegable {if (! Busetime) {return;} if (strhour.match (// d/)! = null) {alert ("Los parámetros de entrada de las horas no son números"); return;} var m = (strHour)? Strhour: New Date (). Gethours (); var s = "<select name = tmpSelECTTHour style = 'font-size: 12px'" s += "onblur = 'document.all.tmpselecthourlayer.style.display =/" none/"" s += = = "onchange = 'document.all.tmpselEcthourlayer.style.display =/" none/";" s+= "parent.meizzthehour = this.value; parent.evasettime (parent.meizzthehour, parent.meizztheminute);'>/r/n"; var selectInnerhtml (i == m) {selectInnerHtml+= "<option value = '"+i+"' seleccionado>"+i+"</opción>/r/n"; } else {selectInnerHtml+= "<option value = '"+i+"'>"+i+"</option>/r/n"; }} selectInnerHtml += "</select>"; odatelayer.tmpselecthourlayer.style.display = ""; odatelayer.tmpselecthourlayer.innerhtml = selectinnerhtml; odatelayer.tmpselecthour.focus ();} function tmpSelectMinuteInnerHtml (strminute) // box de menú desplegable {if (! Busetime) {return;} if (strminute.match (// d/)! = null) {alerta ("¡El parámetro de entrada de minuto no es un número"); return;} var m = (strminute)? strminute: new Date (). getMinutes (); var s = "<select name = tmpselectminute style = 'font-size: 12px'" s += "onblur = 'document.all.tmpselectminututelayer.style.display =/" none/"" s += = = = "onchange='document.all.tmpSelectMinuteLayer.style.display=/"none/";"s += "parent.meizzTheMinute = this.value; parent.evaSetTime(parent.meizzTheHour,parent.meizzTheMinute);'>/r/n";var selectInnerHTML = s;for (var i = 0; i < 60; i ++) {if (i == m) {selectInnerHtml+= "<opción valor = '"+i+"' seleccionado>"+i+"</opción>/r/n"; } else {selectInnerHtml+= "<option value = '"+i+"'>"+i+"</option>/r/n"; }} selectInnerHtml += "</select>"; odatelayer.tmpselectMinutelayer.style.display = ""; odatelayer.tmpselectetminutelayer.innerhtml = selectinnerhtml; odatelayer.tmpselectminute.focus ();} tmpSelectSecondInnerHtml (strSecond) // Segundo cuadro desplegable {if (! Busetime) {return;} if (strSecond.match (// d/)! = null) {alerta ("¡El parámetro de entrada de minuto no es un número"); return;} var m = (strSecond)? strSecond: new Date (). getMinutes (); var s = "<select name = tmpSelectSecond style = 'font-size: 12px'" s += "onblur = 'document.all.tmpselectsecondlayer.style.display =/" none/"'" s += = = " "onchange = 'document.all.tmpselectsecondlayer.style.display =/" none/";" s += "parent.meizztheseCond = this.value; parent.evasettime (parent.meizztheur, parent.meizztheminute, parent.MeizztheseScond);'>/r/r/n"; var SelectInnerhtml. i <60; } else {selectInnerHtml+= "<option value = '"+i+"'>"+i+"</option>/r/n"; }} selectInnerHtml += "</select>"; odatelayer.tmpselectsecondlayer.style.display = ""; odatelayer.tmpselectsecondlayer.innerhtml = selectInnerHtml; odatelayer.tmpselectsecond.focus ();} function Closelayer () {var o = document.getElementById ("endDatelayer"); if (o! = null) {o.style.display = "none";}} function showlayer () // El cierre de esta capa {document.all.enddatelayer.style.display = "";} funcion ispinyear (año) (0 == año%4 && ((año%100! = 0) || (año%400 == 0))) return true; else return false;} function getMonthCount (año, mes) // febrero del año salto es 29 días {var c = monehead [mes-1]; if (mes == 2) & isPinyear (año) c ++; regreso c;} de la semana de un cierto día {var c = monhead [mes-1]; if ((mes == 2) && ispinyear (año)) c ++; return c;} function getdow (día, mes, año) // Encuentre el día de la semana de un día determinado {var dt = nueva fecha (año, mes-1, día) .getay ()/7; return dt;} function meizzPrevy () // Flip Year {if (meizzTheyear> 999 && meizzTheyear <10000) {meizztheyear-;} else {alert ("año de rango (1000-9999)");} meizzSetday (meizztheyear, meizzThemonth);} function meizzne (). Año {if (meizztheyear> 999 && meizztheyear <10000) {meizzTheyear ++;} else {alert ("año fuera de rango (1000-9999)!");} MeizzSetday (meizzTheyear, meizzthemonth);} function setNull () {outobject.value = ''; Closelayer ();};};};} // Botón de hoy {Parent.MeizzTheyear = new Date (). GetFloyear (); Parent.MeizzThemonth = New Date (). GetMonth ()+1; Parent.MeizzThedate = New Date (). GetDate (); Parent.MeizzTheHour = New Date (). Gethours (); Parent.MeizzTheminute = new New Date (). (parent.meizzthedate <10 && parent.meizzthedate.length <2) // formatear en dos dígitos {parent.meizzthedate = "0" + parent.meizzthedate;} // meizzSetday (meizztheyear, meizzthemonth); if (outObject) {if (busetime) {outObject.value = parent. Formato (Parent.MeizzThemonth) + "-" + Format (Parent.MeizzThedate) + "" + Format (Parent.MeizzThehour) + ":" + Format (Parent.MeizzTheminute) + ":" + Format (Parent.Meizzthesecond); // Nota: Aquí puede cambiar la salida al formato que desea} else {outObject.Value = parent.meizzTheyear + "-" + formato (parent.meizzthemonth) + "-" + formato (parent.meizzthedate); // Nota: Aquí puede cambiar la salida al formato que desea}} Closelayer ();} function meizzPrevm () // Siga el mes hacia adelante {if (meizzThemonth> 1) {meizzthemonth-} else {meizzTheyear-; meizzThemonth = 12;} meizzSetDay (meizzTheyear, meizzthemonth);} mes retrocede {if (meizzthemonth == 12) {meizztheyear ++; meizzthemonth = 1} else {meizzthemonth ++} meizzsetday (meizztheyear, meizzthemonth);} // tdo: organizar la función de código meizzsetday (yy, mm) // el programa de escritura principal *************** {meizzwritehead (yy, mm); // Establezca la variable pública del año y el mes en curso para pasar el valor meizzTheyear = yy; meizzthemonth = mm; para (var i = 0; i <37; i ++) {meizzwway [i] = "}; // Borrar todo el contenido del cuadro de visualización var day1 = 1, day2 = 1, primer día = nueva fecha (yy, mm-1,1) .getday (); // ¿Qué día de la semana del primer día de un determinado mes para (i = 0; i <primer día; i ++) meizzwday [i] = getMonthCount (mm == 1? Yy-1: yy, mm ==? 12: mm-1) -firstday+i+1 // los últimos días de los últimos meses para (i = primer día; day1 <getmonthcount (yy 1, mm); meizzwday [i] = day1; día1 ++; } para (i = primer día+getMonthCount (yy, mm); i <37; i ++) {meizzwday [i] = day2; day2 ++; } para (i = 0; i <37; i ++) {var da = eval ("odatelayer.meizzday"+i) // con la fecha y el arreglo de la semana del nuevo mes if (meizzwday [i]! = "") {// Inicializar el borde Da.borderColorLight = "#63A3E9"; da.bordercolark = "#63a3e9"; da.style.color = "#1478eb"; if (i <primer día) // La parte del mes pasado {da.innerhtml = "<b> <font color =#bcbabc>" + meizzwday [i] + "</font> </b>"; da.title = (mm == 1? 12: mm-1) + "mes" + meizzwday [i] + "día"; da.OnClick = function ("MeizzdayClick (this.inntext, -1)"); if (! waskate) da.style.backgroundcolor = ((mm == 1? yy-1: yy) == new date (). getFlyear () && (mm == 1? 12: mm-1) == nueva fecha (). getMonth ()+1 && meizzwday [i] == new date (). getDate ())? "#5cefa0": "#f5f5f5"; else {da.style.backgroundcolor = ((mm == 1? yy-1: yy) == Outdate.getblyaryear () && (mm == 1? 12: mm-1) == Outdate.getmonth () + 1 && meizzwday [i] == Outdate.getDate ())? "#84c1ff": (((mm == 1? Yy-1: yy) == new date (). GetFloyear () && (mm == 1? 12: mm-1) == New Date (). GetMonth ()+1 && meizzwday [i] == nueva fecha (). GetDate ())? "#5CEFA0": "#F5f5f5"); // Mostrar la fecha seleccionada como cóncavo if ((mm == 1? Yy-1: yy) == windate.getblyear () && (mm == 1? 12: mm-1) == Overdate.getmonth () + 1 && meizzwday [i] == Overdate.getDate ()) {Da.BorDorDolorlight = "#ffffff";; da.bordercolark = "#63a3e9"; }}} else if (i> = primer día + getMonthCount (yy, mm)) // La parte del próximo mes {da.innerhtml = "<b> <font color =#bcbabc>" + meizzwday [i] + "</font> </b>"; da.title = (mm == 12? 1: mm + 1) + "mes" + meizzwday [i] + "día"; da.OnClick = function ("MeizzdayClick (this.inntext, 1)"); if (! waskate) da.style.backgroundcolor = ((mm == 12? yy+1: yy) == new date (). getFlyear () && (mm == 12? 1: mm+1) == New Date (). getMonth ()+1 && meizzwday [i] == new Date (). GetDate ())? "#5cefa0": "#f5f5f5"; else {da.style.backgroundcolor = ((mm == 12? yy+1: yy) == Outdate.getblyaryear () && (mm == 12? 1: mm+1) == winkate.getmonth ()+1 && meizzwday [i] == Outdate.getDate ())? "#84c1ff": (((mm == 12? Yy+1: yy) == new Date (). GetFloyear () && (mm == 12? 1: mm+1) == New Date (). GetMonth ()+1 && meizzwday [i] == new Date (). // Muestre la fecha seleccionada como cóncavo if ((mm == 12? Yy+1: yy) == windate.getblyear () && (mm == 12? 1: mm+1) == Overy.getmonth ()+1 && meizzwday [i] == Overdate.getDate ()) {Da.BorDertolorLight = "#ffffff"; da.bordercolark = "#63a3e9"; }}} más // parte de este mes {da.innerhtml = "<b>" + meizzwday [i] + "</b>"; da.title = mm + "mes" + meizzwday [i] + "día"; da.OnClick = function ("MeizzdayClick (this.inntext, 0)"); // dar a TD el procesamiento del evento OnClick // Si es la fecha seleccionada actualmente, se mostrará un fondo azul brillante; Si es la fecha actual, se mostrará un fondo amarillo oscuro si (! Outkate) da.Style.BackgroundColor = (yy == new Date (). GetLyEar () && mm == New Date (). GetMonth ()+1 && meizzwday [i] == New Date (). GetDate ())? "#5cefa0": "#f5f5f5"; else {da.style.backgroundcolor = (yy == windate.getblyear () && mm == windate.getmonth () + 1 && meizzwday [i] == Outdate.getDate ())? "#84c1ff": ((yy == new Date (). GetFlyear () && mm == New Date (). GetMonth ()+1 && meizzwday [i] == New Date (). GetDate ())? "#5CEFA0": "#F5F5F5"); // Muestra la fecha seleccionada como cóncavo if (yy == windate.getblyear () && mm == Outdate.getMonth () + 1 && meizzwday [i] == Overdate.getDate ()) {da.bordercolorlight = "#fffffff"; da.bordercolark = "#63a3e9"; }}} da.style.cursor = "hand"} else {da.innerhtml = ""; da.style.backgroundcolor = ""; da.style.cursor = "default"; }}} function meizzdayclick (n, ex) // Haga clic en el cuadro de visualización para seleccionar la fecha, la función de entrada principal ************************** {parent.meizzthedate = n; var yy = meizztheyear; var mm = parseint (meizzthemonth)+ex; // EX representa el desplazamiento, utilizado para seleccionar la fecha del mes anterior y el mes siguiente VAR HH = MEIZZTHEUR; var mi = meizztheminute; var se = meizztheseCond; // juzga el mes y realiza el procesamiento correspondiente si (mm <1) {yy--; mm = 12+mm;} else if (mm> 12) {yy ++; mm = mm-12;} if (mm <10) {mm = "0" + mm;} if (hh <10) {hh = "0" + hh;} // tiempo if (mi <10) {mi = "0" + mi;} // minutos if (se <10) {se = "0" + se;} // if (outObject) //outobject.Value= ""; return;} if (n <10) {n = "0" + n;} WriteTateto (yy, mm, n, hh, mi, se); Closelayer (); if (Busetime) {try {outButton.click (); } catch (e) {setday (outObject); }}} else {CloseLayer (); alerta ("El objeto de control que desea emitir no existe!");}} formato de función (n) // formatear el número como caracteres de dos dígitos para representar {var m = new String (); var tmp = new String (n); if (n <10 && tmp.length <2) {m = "0"+n;} else {m = m = n;} return m;} function modeetTime () Seleccionado por el usuario {odatelayer.meizzhourhead.inntext = meizzthehour+"time"; odatelayer.meizzminutehead.inntext = meizztheminute+"minuto; odatelayer.meizzsecondhead.innertext = meizztheseCond+" segundos "; Writedateto (Meizztheyear, Meizzthemonth, Meizzthedate, Meizztheur, Meizztheminute, MeizztheseCond)} Función EvasetTimeNothing () // Controle el control del tiempo vacío {odatelayer.meizzhourhead.inntext = ""; odatelayer.meizzminutehead.inntext = ""; odatelayer.meizzsecondhead.innertext = ""; writeTateto (meizztheyear, meizztemonth, meizzthedate, meizzthehury, meizztheminute, meizzthes. evasetTimeNow () // establece el control de tiempo en la hora actual {odatelayer.meizzhourhead.inntext = new date (). gethours ()+"tiempo"; odatelayer.meizzminuteute.inntext = new date (). getMinutes ()+"minutos"; odatelayer.meizzsecondhead.inntext. Date (). Date (). tiempo, el tiempo seleccionado originalmente por el usuario // evasettimeNow (); formato (mm) + "-" + formato (n) + "" + formato (hh) + ":" + formato (mi) + ":" + formato (se); want}} function bimgSwitch () {if (Busetime) {bimg = "on";} else {bimg = "off";}} </script> <input onfocus = "setday (this)" id = "starttime" name = "starttime">>>For more information about JavaScript, please check this site's special topics: "Summary of JavaScript Time and Date Operation Skills", "Summary of JavaScript Switching Effects and Skills", "Summary of JavaScript Search Algorithm Skills", "Summary of JavaScript Animation Special Effects and Skills", "Summary of JavaScript Errors and Debugging Skills", "Summary of JavaScript Data Structures and Algorithm Skills", "Resumen del algoritmo y habilidades de traversal de JavaScript" y "Resumen del uso de la operación matemática de JavaScript"
Espero que este artículo sea útil para la programación de JavaScript de todos.