Este artículo describe el hermoso efecto de selección de tiempo de JS. Compártelo para su referencia, como sigue:
Parte del código HTML:
<html> <script language = javascript src = "dataone.js"> </script> <table align = "centro"> <tr> <td> <body> (1) seleccione solo fecha <input type = "text" name = "date" readonly onclick = "setday (this);"> <br/> (2) seleccione la fecha y hora <input type = "text" name = " onClick = "Setdayh (this);"> <br/> (3) Seleccione Fecha y hora y minuto <input type = "text" name = "datehm" readonly onclick = "setdayhm (this);"> </body> </td> </tr> </table> </html>
Código DataOne.js:
/*** Método de uso: * (1) Seleccione solo fecha <input type = "text" name = "date" readonly onclick = "setday (this);"> * (2) seleccione Fecha y hora <Input Type = "Text" Name = "Dateh" Readonly OnClick = "Setdayh (this);"> * (3) Seleccione Fecha y hora y minuto <Tipo de entrada = "Text" Nombre = "Datehm" Readonly "Readonly onClick = "setdayhm (this);"> * Método para configurar los parámetros * (1) Establezca el separador de fecha SetDatesPlit (STRSPLIT); El valor predeterminado es "-" * (2) establecer el separador entre la fecha y la hora setDateTimesPlit (strsplit); El valor predeterminado es "" * (3) establecer el tiempo separador settimesplit (strsplit); El valor predeterminado es ":" * (4) Establezca el separador en (1), (2), (3) setsplit (strdatesplit, strdateTimesplit, strTimesplit); * (5) Establezca el año de inicio y finalización setyearperiod (intdateBeg, intdateend) * Descripción: * El formato de fecha y hora devuelto predeterminado es el siguiente: 2005-02-02 08:08 */ // ------------------------------------------------------------------------------------------------------------------------------------------------------- "Altura: 16px; Font-Size: 9PT; Color: White; Border: 0 Solid #CCCCCC; Cursor: Hand; Background-Color: #2650a6;"; // botones para durante todo el año, mes, etc. var s_tiannet_turn = "width: 28px;" + S_TIANNET_TURN_BASE; // Cerrar, borrar, etc. estilos de botón var s_tiannet_turn2 = "width: 22px;" + S_TIANNET_TURN_BASE; // Seleccione el cuadro desplegable para VAR durante todo el año S_Tiannet_Select = "Width: 64px; Display: None;"; // Seleccione el cuadro desplegable de mes, hora y minuto var s_tiannet_select2 = "width: 46px; display: none;"; // Control de selección de fecha Estilo del cuerpo Var S_tiannet_body = "Ancho: 150; Color de fondo:#2650a6; Display: Ninguno; Z-índice: 9998; Posición: Absolte;" + "Border-izquierda: 1 sólido #cccc; border-top: 1 sólido #cccc; border-right: 1 sólido #999999; botón de borde: 1 sólido #999999;"; // Estilo del TD que muestra el día var s_tiannet_day = "ancho: 21px; altura: 20px; fondo de fondo:#d8f0fc; font-size: 10pt;"; // estilo de fuente var s_tiannet_font = "color:#ffcc00; font-size: 9pt; cursor: hand;"; // estilo de enlace var s_tiannet_link = "Text-Decoration: None; Font-Size: 9PT; Color:#2650a6;"; // Horily Line var s_tiannet_line = "border-bottom: 1 sólido #6699cc"; // ----------------------------------------------------------------------------------------------------------------------------------------------------------- 2010; // Año final seleccionable var tiannetDatenow = new Date (); var tiannetyear = tiannetdatenow.getblyear (); // El valor inicial del año de definición variable var tiannetmonth = tiannetdatenow.getMonth ()+1; // El valor inicial del mes de definición variable var tiannetday = tiannetdatenow.getDate (); var tiannetHour = 8; // tiannetdatenow.gethours (); var tiannetminute = 0; // tiannetdatenow.getminutes (); var tiannetarrday = nueva matriz (42); // matriz que define la fecha var tiannetDatesplit = "-"; // Fecha de separador var tiannetDateTimesplit = ""; // Fecha de separador var tiannettimesplit = ":"; // Time Separator var tiannetoutObject; // objeto que recibe fecha y hora var arrtiannethide = new Array (); // La etiqueta que se ve obligada a estar oculta var m_bolshowhour = false; // hace la hora var m_bolshowminute = false; // si para mostrar minutos var m_amonhead = new array (12); // Defina el número máximo de días por mes en el calendario gregoriano M_amonhead [0] = 31; m_amonhead [1] = 28; m_amonhead [2] = 31; m_amonhead [3] = 30; m_amonhead [4] = 31; m_amonhead [5] = 30; m_amonhead [6] = 31; m_amonhead [7] = 31; m_amonhead [8] = 30; m_amonhead [9] = 31; m_amonhead [10] = 30; m_amonhead [11] = 31; // ----------------------------------------------------------- // Si hay un valor en la etiqueta, inicialice la fecha en el valor actual var strValue = tiannettrim (tiannetOutObject.Value); if (strValue! = "") {TiannetInitDate (strValue); } tiannetPopCalendar (); } // Función de llamadas principales del usuario: seleccione Fecha y función de hora SetDayh (OBJ) {TianNetOutObject = obj; m_bolshowhour = true; // Si hay un valor en la etiqueta, la fecha y la hora se inicializan al valor actual var strValue = Tiannettrim (TiannetOutObject.Value); if (strValue! = "") {TiannetInitDate (strValue.substring (0,10)); var hora = strValue.sUstring (11,13); if (hora <10) tiannethour = hora.substring (1,2); } tiannetPopCalendar (); } // Función de llamada principal del usuario: seleccione Fecha y función de hora y minuto SetDayHM (OBJ) {TianNetOutObject = obj; m_bolshowhour = true; m_bolshowminute = true; // Si hay un valor en la etiqueta, inicialice la fecha, hora y minuto al valor actual var strValue = Tiannettrim (TiannetOutObject.Value); if (strValue! = "") {TiannetInitDate (strValue.substring (0,10)); var tiempo = strValue.sUstring (11,16); var arrr = time.split (Tiannettimesplit); TiannetHour = arr [0]; tiannetminute = arr [1]; if (tiannethour <10) tiannethour = tiannethour.substring (1,2); if (tiannetminute <10) tiannetminute = tiannetminute.substring (1,2); } tiannetPopCalendar (); } // Establecer la función de fecha de inicio y la fecha de finalización setyearperiod (intdateBeg, intdateend) {tiannetyearst = intdateBeg; tiannetyearend = intdateend; } // Establecer el separador de fecha. La función predeterminada es "-" setDatesPlit (strdatesplit) {tiannetDatesplit = strdatesplit; } // Establezca el separador entre fecha y hora. La función predeterminada es "" setDateTimesPlit (strdateTimesPlit) {TiannetDateTimesPlit = strdateTimesPlit; } // Establecer el separador de tiempo. El valor predeterminado es ":" función settimesplit (strTimesplit) {tiannettimesplit = strTimesplit; } // Establezca la función separadora setsplit (strdatesplit, strdateTimesplit, strTimesplit) {tiannetDatesplit (strdatesplit); TiannetDateTimesPlit (strdateTimesplit); Tiannettimesplit (strtimesplit); Tiannettimesplit (strtimesplit); } // Establecer la fecha predeterminada. El formato es: yyyy-mm-dd función setDefaultDate (strdate) {tiannetyear = strdate.substring (0,4); tiannetmonth = strdate.substring (5,7); Tiannetday = strdate.substring (8,10); } // Establecer el tiempo predeterminado. El formato es: hh24: mi función setDefaulttime (strtime) {tiannetHour = strtime.substring (0,2); tiannetminute = strtime.substring (3,5); } // ----------------------------------------------------------------------------------------------------------------------------------------------- style = "'+S_tiannet_body+'" style = "Este control de selección de calendario se mejora con Tiannet en función de la experiencia de las generaciones anteriores!"> '); document.write ('<div align = "center" id = "divtiannetdatetext" autor = "tiannet" style = "padding-top: 2px;">'); document.write ('<span id = "tiannetyearhead" autor = "tiannet" style = "'+s_tiannet_font+'"'+'onClick = "spanyearcevent ();"> año </span>'); document.write ('<select id = "seltianyear" style = "'+s_tiannet_select+'" autor = "tiannet"'+'onchange = "tiannetyear = this.value; tiannetsetday (tiannetyear, tiannetmonth); document.all.tiannetyearhead.style.display =/'; '+' 'this.style.display =/' none/'; ">'); for (var i = tiannetyearst; i <= tiannetyearend; i ++) {document.writeLn ('<option value = "' + i + '">' + i + 'año </option>'); } document.write ('</elect>'); document.write ('<span id = "tiannetmonthhead" autor = "tiannet" style = "'+s_tiannet_font+'"'+'onClick = "spanmonthcevent ();"> mes </span>'); document.write ('<select id = "seltianmonth" style = "'+s_tiannet_select2+'" autor = "tiannet"'+'onchange = "tiannetmonth = this.value; tiannetsetday (tiannetyear, tiannetmonth); document.all.tiannetmonthhead.style.display =/'; '+; 'this.style.display =/' none/'; ">'); for (var i = 1; i <= 12; i ++) {document.writeLn ('<option value = "' + i + '">' + i + 'mes </option>'); } document.write ('</elect>'); //document.write ('</div>'); //document.write('<Div align = "Center" id = "DivTianNetTimetext" autor = "Tiannet"> '); document.write ('<span id = "tiannethourhead" autor = "tiannet" style = "'+s_tiannet_font+'visual document.write ('<select id = "seltianhour" style = "'+s_tiannet_select2+'visual 'this.style.display =/' none/'; ">'); for (var i = 0; i <= 23; i ++) {document.writeLn ('<option value = "' + i + '">' + i + 'time </option>'); } document.write ('</elect>'); document.write ('<span id = "tiannetminutehead" autor = "tiannet" style = "'+s_tiannet_font+'visual document.write ('<select id = "seltianminute" style = "'+s_tiannet_select2+'visual 'this.style.display =/' none/'; ">'); for (var i = 0; i <= 59; i ++) {document.writeLn ('<option value = "' + i + '">' + i + 'punto </option>'); } document.write ('</elect>'); document.write ('</div>'); // emite una línea horizontal document.write ('<div style = "'+S_tiannet_line+'"> </div>'); document.write ('<div align = "center" id = "divtiannetTurn" style = "border: 0;" autor = "Tiannet">'); document.write ('<input type = "button" style = "'+s_tiannet_turn+'" value = "año ↑" onClick = "TiannetPreVyear ();">'); document.write ('<input type = "button" style = "'+s_tiannet_turn+'" valor = "año ↓" onClick = "TiannetNextyear ();">'); document.write ('<input type = "button" style = "'+s_tiannet_turn+'" valor = "año ↓" onClick = "TiannetNextyear ();">'); document.write ('<input type = "button" style = "'+s_tiannet_turn+'" value = "mes ↑" onClick = "TiannetPrevmonth ();">'); document.write ('<input type = "button" style = "'+s_tiannet_turn+'" value = "mes ↓" onClick = "TiannetNextmonth ();">'); document.write ('</div>'); // emite una línea horizontal document.write ('<div style = "'+S_tiannet_line+'"> </div>'); document.write ('<table border = 0 cellspacing = 0 cellPadding = 0 bgcolor = white onSelectStart = "return false">'); document.write ('<tr style = "de fondo de fondo:#2650a6; font-size: 10pt; color: blanco; altura: 22px;" autor = "Tiannet">'); for (var i = 0; i <weekname.length; i ++) {// emitir entre semana document.write ('<td align = "center" autor = "Tiannet">' + WeekName [i] + '</td>'); } document.write ('</tr>'); document.write ('</table>'); // Seleccionar el día de salida document.write ('<table border = 0 cellPacing = 1 CellPadding = 0 BGColor = White OnSelectStart = "return False">'); var n = 0; for (var i = 0; i <5; i ++) {document.write ('<tr align = center id = "trtiannetday' + i + '">'); for (var j = 0; j <7; j ++) {document.write ('<td align = "center" id = "tdtiannetday' + n + '' + 'onClick =" tiannetday = this.innteText; tianNetSetValue (true); "' + 'style ="' + s_tiannet_day + '' "> </td> '); n ++; } document.write ('<tr align = center id = "trtiannetday5">'); document.write ('<td align = "center" id = "tdtiannetday35" onClick = "tiannetday = this.inntext; tiannetSetValue (true);"' + 'style = "' + s_tiannet_day + '"> </td>'); document.write ('<td align = "center" id = "tdtiannetday36" onClick = "tiannetday = this.inntext; tiannetSetValue (true);"' + 'style = "' + s_tiannet_day + '"> </td>'); document.write ('<td align = "right" colspan = "5"> <a href = "javascript: tiannetclear ();" style = "' + s_tiannet_link + '"> clare </a>' + '<a href = "javascript: tiannEnTeControl ();" style = " + s_tiannetnetnetnet' + '» '<a href = "javascript: tiannetsetValue (true);" style = "' + s_tiannet_link + '"> ok </a>' + '</td>'); document.write ('</tr>'); document.write ('</table>'); document.write ('</div>'); // ----------------------------------------------------------------------------------------------------------------------------------------------------------- Array ("Seltianyear", "Tiannetmonthhead"), falso); if (m_bolshowhour) hideElementsById (nueva matriz ("TiannetHourhead"), falso); if (m_bolshowminute) hideElementsById (nueva matriz ("Tiannetminutehead"), falso); HideElementsById (New Array ("TiannetyArhead", "Seltianmonth", "Seltianhour", "Seltianminute"), verdadero); } // Haga clic en la etiqueta del tramo de mes para responder la función spanmonthcEvent () {hideElementsById (nueva matriz ("seltianmonth", "tiannetyearhead"), falso); if (m_bolshowhour) hideElementsById (nueva matriz ("TiannetHourhead"), falso); if (m_bolshowminute) hideElementsById (nueva matriz ("Tiannetminutehead"), falso); HideElementsById (New Array ("Tiannetmonthhead", "Seltianyear", "Seltianhour", "SeltianMinute"), verdadero); } // Haga clic en la función de respuesta de la etiqueta del tramo de hora spanHourcevent () {hideElementsById (nueva matriz ("TiannetyArhead", "TiannetMonthhead"), falso); if (m_bolshowhour) hideElementsById (nueva matriz ("Seltianhour"), falso); if (m_bolshowminute) hideElementsById (nueva matriz ("Tiannetminutehead"), falso); HideElementsById (nueva matriz ("Tiannethourhead", "Seltianyear", "Seltianmonth", "Seltianminute"), verdadero); } // Haga clic en la función de respuesta de la etiqueta del tramo de minuto SpanMinuteCeVent () {HideElementsById (New Array ("TiannetyArhead", "Tiannetmonthhead"), falso); if (m_bolshowhour) hideElementsById (nueva matriz ("TiannetHourhead"), falso); if (m_bolshowminute) hideElementsById (nueva matriz ("seltianminute"), falso); HideElementsById (nueva matriz ("TiannetMinutehead", "Seltianyear", "SeltianMonth", "Seltianhour"), verdadero); } // ocultar o mostrar la función de etiqueta hideElementsById (arrid, bolhide) {var strdisplay = "" "; if (bolhide) strdisplay = "ninguno"; for (var i = 0; i <arrid.length; i ++) {var obj = document.getElementById (arrid [i]); obj.style.display = strdisplay; }} // ------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------- if ((mes == 2) && ispinyear (año)) c ++; regreso c; } // Restablecer el día actual. Principalmente para evitar que el día actual sea mayor que el día máximo del mes en que el año se anule o se anule el mes. function setReaLDAYCount () {if (Tiannetday> getMonthCount (Tiannetyear, TiannetMonth)) {// Si el día actual es mayor que el día máximo del mes, entonces se toma el día máximo del mes. Tiannetday = GetMonthCount (Tiannetyear, Tiannetmonth); }} // Agregar cero antes de la función de dígitos únicos addzero (valor) {if (valor <10) {valor = "0" + valor; } valor de retorno; } // Recuperar la función de espacio Tiannettrim (str) {return str.replace (/(^/s*) | (/s*$)/g, ""); } // Cree una función de opción CreateOption (objelect, value, text) {var option = document.createElement ("opción"); opción.value = valor; opción.text = text; objelect.options.add (opción); } // FUNCIÓN DEL AÑO FORDE ADELA TiannetPRevyear () {if (Tiannetyear> 999 && Tiannetyear <10000) {Tiannetyear--;} else {alerta ("Año fuera del rango (1000-9999)!");} TiannetSetday (tiannetyear, tiannetonthmonth); // Si el año es menor que el año mínimo permitido, cree la opción correspondiente if (Tiannetyear <TiannetyEarst) {TiannetyEarst = Tiannetyear; createOption (document.all.seltianyear, tiannetyear, tiannetyear + "año"); } checkSelect (document.all.seltianyear, tiannetyear, tiannetyear); tiannetwritehead (); } // Función de año Flip TiannetNextyear () {if (tiannetyear> 999 && tiannetyear <10000) {tiannetyear ++;} else {alert ("año fuera de rango (1000-9999)!"); return;} Tiannetsetday (Tiannetyear, Tiannetmonth); // Si el año excede el año máximo permitido, cree la opción correspondiente if (tiannetyear> tiannetyearend) {tiannetyearend = tiannetyear; createOption (document.all.seltianyear, tiannetyear, tiannetyear + "año"); } checkSelect (document.all.seltianyear, tiannetyear, tiannetyear); tiannetwritehead (); } // Seleccione la función hoy TiannetToday () {Tiannetyear = TiannetDatenow.getTliplyear (); tiannetmonth = tiannetdatenow.getmonth ()+1; tiannetday = tiannetdatenow.getDate (); TiannetsetValue (verdadero); // Tiannetsetday (Tiannetyear, Tiannetmonth); // selectObject (); } // Siga la función de mes del mes TiannetPrevmonth () {if (Tiannetmonth> 1) {TiannetMonth-} else {Tiannetyear-; tiannetmonth = 12;} Tiannetsetday (tiannetyear, tiannetmonth); checkSelect (document.all.seltianmonth, Tiannetmonth); tiannetwritehead (); } // Sigue la función de mes TiannetNextmonth () {if (TiannetMonth == 12) {Tiannetyear ++; Tiannetmonth = 1} else {Tiannetmonth ++} TiannetSetday (Tiannetyear, TiannetMonth); checkSelect (document.all.seltianmonth, Tiannetmonth); tiannetwritehead (); } // Escribir año, mes, tiempo, minuto y otros datos en la función de etiqueta de span tiannetwritehead () {document.all.tiannetyearhead.inntext = tiannetyear + "año"; document.all.tiannetmonthhead.inntext = tiannetmonth + "mes"; if (m_bolshowhour) document.all.tiannethourhead.inntext = "" + TiannetHour + "Time"; if (m_bolshowminute) document.all.tiannetminutehead.inntext = tiannetminute + "minutos"; TianNetSetValue (falso); // Asigne valores al cuadro de texto, pero no oculte este control} // Establezca la función de día de visualización TiannetSetday (yy, mm) {setReAlDayCount (); // Establezca el día real del mes TianNetWritehead (); var strdateFont1 = "", strdateFont2 = "" // Entrena el estilo de la pantalla de la fecha para (var i = 0; i <37; i ++) {tiannetarrday [i] = ""}; // Borrar todo el contenido del cuadro de visualización var day1 = 1; var primer día = nueva fecha (yy, mm-1,1) .getday (); // Día de la semana del primer día de un cierto mes para (var i = primer día; día1 <getMonthcount (yy, mm) +1; i ++) {tiannetarrday [i] = day1; day1 ++; } // Si el valor de la primera celda utilizada para mostrar la última fila del día está vacía, oculte toda la fila. // if (tiannetarrday [35] == "") {// document.all.trtiannetday5.style.display = "none"; //} else {// document.all.trtiannetday5.style.display = ""; //} para (var i = 0; i <37; i ++) {var da = eval ("document.all.tdtiannetday"+i) // escribiendo el arreglo de fecha y semana del nuevo mes if (tiannetarrday [i]! = "") {// juzga si es un fin de semana, si es un fin de semana, cambia a Font Red Font si (i % 7 == 0 || (i+1) %) strdateFont1 = "<font color =#f0000>" strdateFont2 = "</font>"} else {strdateFont1 = ""; strdateFont2 = ""} da.innerhtml = strdateFont1 + tiannetarrday [i] + strdateFont2; // Si es el día seleccionado actualmente, cambie el color if (tiannetarrday [i] == Tiannetday) {da.style.backgroundcolor = "#ccccccc"; } else {da.style.backgroundcolor = "#efef"; } Da.style.cursor = "Hand"} else {da.innerhtml = ""; da.style.backgroundcolor = ""; da.style.cursor = "predeterminado"}} // end para tiannetSetValue (falso); // Asignar un valor a la casilla de texto, pero no escondite este control} // en final de la función TianNetSet // SEEL checkSelect (objSelect, selectValue) {var count = parseInt (objSelect.length); if (selectValue <10 && selectValue.ToString (). longitud == 2) {selectValue = selectValue.substring (1,2); } for (var i = 0; i <count; i ++) {if (objSelect.options [i] .value == selectValue) {objSelect.SelectedIndex = i; romper; }} // para} // Seleccione la función de cuadro desplegable selectObject () {// Si el año es menor que el año mínimo permitido, cree la opción correspondiente if (tiannetyear <tiannetyearst) {for (var i = tiannetyear; i <tiannetyearst; i ++) {createOption (document.all.seltianyear, i + "año"); ");"); } tiannetyearst = tiannetyear; } // Si el año excede el año máximo permitido, cree la opción correspondiente if (tiannetyear> tiannetyArend) {for (var i = tiannetyearend + 1; i <= tiannetyear; i ++) {createOption (document.all.seltianyear, i, i + "año"); } tiannetyearend = tiannetyear; } checkSelect (document.all.seltianyear, tiannetyear); checkSelect (document.all.seltianmonth, Tiannetmonth); if (m_bolshowhour) checkSelect (document.all.seltianhour, tiannethour); if (m_bolshowminute) checkSelect (document.all.seltianminute, tiannetminute); } // Asigna un valor al control que acepta fecha y hora // Parámetros Bolhidecontrol - si para ocultar la función de control TiannetSetValue (Bolhidecontrol) {var value = ""; if (! Tiannetday || tiannetday == "") {tiannetOutObject.Value = value; devolver; } var mm = tiannetmonth; var día = Tiannetday; if (mm <10 && mm.ToString (). longitud == 1) mm = "0" + mm; if (día <10 && day.ToString (). Longitud == 1) Day = "0" + Día; valor = tiannetyear + tiannetdatesplit + mm + tiannetdatesplit + day; if (m_bolshowhour) {var hora = tiannethour; if (hora <10 && hour.ToString (). Longitud == 1) Hour = "0" + hora; valor + = tiannetdateTimesplit + hora; } if (m_bolshowminute) {var minuto = tiannetminute; if (minuto <10 && mind.ToString (). longitud == 1) minuto = "0" + minuto; valor + = tiannettimesplit + minuto; } tiannetoutObject.Value = value; //document.all.divtiannetdate.style.display = "ninguno"; if (bolhidecontrol) {tiannethidecontrol (); }} // ¿Muestra la función de tiempo showtime () {if (! M_bolshowhour && m_bolshowminute) {alert ("Si desea seleccionar minutos, ¡debe poder seleccionar horas!"); devolver; } HideElementsById (nueva matriz ("Tiannethourhead", "Seltianhour", "Tiannetminutehead", "Seltianminute"), verdadero); if (m_bolshowhour) {// show horas hideElementsById (nueva matriz ("TiannetHourhead"), falso); } if (m_bolshowminute) {// Muestra minutos HideElementsById (nueva matriz ("TiannetHourhead"), falso); } if (m_bolshowminute) {// Muestra minutos hideElementsById (new Array ("TiannetMinutehead"), falso); }} // El control de selección de calendario aparece para permitir que el usuario seleccione la función TiannetPopCalendar () {// Ocultar el cuadro desplegable para mostrar el cabezal correspondiente HideElementsById (New Array ("Seltianyear", "SeltianMonth", "SeltianHour", "SeltianMinute"), verdadero); HideElementsById (nueva matriz ("TiannetyArhead", "Tiannetmonthhead", "TiannetMinutehead"), falso); Tiannetsetday (Tiannetyear, Tiannetmonth); tiannetwritehead (); tiempo de la funcion(); var dads = document.all.divtiannetdate.style; var ix, iy; var h = document.all.divtiannetdate.offsetheight; var w = document.all.divtiannetdate.offsetWidth; // Calcule la izquierda if (window.event.x + h> document.body.offsetwidth - 10) ix = window.event.x - h - 5; else ix = window.event.x + 5; if (ix <0) ix = 0; // Calcule Top iy = Window.event.y; if (window.event.y + w> document.body.offsetheight - 10) iy = document.body.scrolltop + document.body.offsetheight - w - 5; else iy = document.body.scrolltop + window.event.y + 5; if (iy <0) iy = 0; Dads.left = ix; Dads.top = iy; TiannetShowControl (); selectObject (); } // ocultar el control del calendario (que muestra las etiquetas ocultas forzadas al mismo tiempo) función tiannethidecontrol () {document.all.divtiannetdate.style.display = "none"; TiannetShowObject (); arrtiannethide = new array (); // borrar el objeto de etiqueta oculto} // show calendar control (ocultar las etiquetas oscurecidas al mismo tiempo) función tiannetshowControl () {document.all.divtiannetdate.style.display = ""; TiannethideObject ("Seleccionar"); tiannethideObject ("objeto"); } // Ocultar etiquetas según el nombre de la etiqueta. Si la selección del control se bloqueará, la función de objeto tiannethideObject (strtagname) {x = document.all.divtiannetdate.offsetleft; y = document.all.divtiannetdate.offsettop; h = document.all.divtiannetdate.offsetheight; w = document.all.divtiannetdate.offsetWidth; for (var i = 0; i <document.all.tags (strtagname) .length; i ++) {var obj = document.all.tags (strtagname) [i]; if (! obj ||! obj.offsetParent) continuar; // Obtenga las coordenadas relativas del elemento para la etiqueta del cuerpo var objleft = obj.offsetleft; var objtop = obj.offsettop; var objheight = obj.offsetheight; var objWidth = obj.offsetWidth; var objParent = obj.OffSetParent; while (objparent.tagname.touppercase ()! = "cuerpo") {objleft += objParent.offsetleft; objtop += objparent.offsettop; objparent = objparent.offsetParent; } // alerta ("extremo izquierdo del control:" + x + "seleccione el extremo izquierdo" + (objleft + objwidth) + "fondo del control:" + (y + h) + "seleccione alto:" + objtop); var bolhide = true; if (obj.style.display == "ninguno" || obj.style.visibility == "oculto" || obj.getAttribute ("autor") == "Tiannet") {// Si la etiqueta en sí está oculta, ya no es necesario ocultar. Si se trata de un cuadro desplegable en el control, no necesita estar oculto. Bolhide = falso; } if( ( (objLeft + objWidth) > x && (y + h + 20) > objTop && (objTop+objHeight) > y && objLeft < (x+w) ) && bolHide ){ //arrTiannetHide.push(obj);//Record hidden tag object arrTiannetHide[arrTiannetHide.length] = obj; obj.style.visibility = "Hidden"; }}} // Mostrar función de etiqueta oculta TiannetShowObject () {for (var i = 0; i <arrtiannethide.length; i ++) {// alert (arrtiannethide [i]); arrtiannethide [i] .style.visibility = ""; }} // Fecha de inicialización. función tiannetinitdate (strdate) {var arr = strdate.split (tiannetDatesplit); tiannetyear = arr [0]; tiannetmonth = arr [1]; Tiannetday = arr [2]; } // claro function tiannetClear () {tianNetOutObject.value = ""; tiannethidecontrol (); } // Cierre el control al hacer clic en cualquier función document.onclick () {con (window.event.sricleement) {if (tagName! = "Input" && getAttribute ("autor")! = "Tiannet") tiannethidecontrol (); }} // Presione la tecla ESC para cerrar la función de control document.OnkeyPress () {if (event.keyCode == 27) {tiannethidecontrol (); }}For more information about JavaScript related content, please check out the topics of this site: "Summary of JSON operation skills in JavaScript", "Summary of JavaScript switching effects and techniques", "Summary of JavaScript search algorithm skills", "Summary of JavaScript animation special effects and techniques", "Summary of JavaScript errors and debugging skills", "Summary of JavaScript data structures and Habilidades de algoritmo "," Resumen de los algoritmos y técnicas de traversal JavaScript "y" Resumen del uso de operaciones matemáticas de JavaScript "
Espero que este artículo sea útil para la programación de JavaScript de todos.