Este artigo descreve o belo efeito da caixa de seleção do tempo do JS. Compartilhe -o para sua referência, como segue:
Parte do código HTML:
<html> <idioma script = javascript src = "DataOne.js"> </script> <tabela align = "Center"> <tr> <td> <body> (1) Selecione apenas data <input type = "text" name = "date" readOnly onClick = "setday (typedday" " ONCLICK = "SetDayh (this);"> <br/> (3) Selecione Data e hora e minuto <insput type = "text" name = "datehm" readOnly onclick = "SetDayhm (this);"> </body> </td> </tr> </ tabela> </html>
Dataone.js Código:
/*** Método de uso: * (1) Selecione Somente data <input type = "text" name = "date" readonly onclick = "setday (this);"> * (2) Selecione Data e hora <Tipo de entrada = "Text" Name = "Dateh" ReadOnly OnClick = "setDayh (this);"> (3) Select Date e Hour e Minute " OnClick = "setDayhm (this);"> * Método para definir parâmetros * (1) Defina a data Separator SetDatesplit (strsplit); O padrão é "-" * (2) Defina o separador entre a data e a hora SetDateTimesPlit (strsplit); O padrão é "" * (3) Defina o intervalo de tempo de separador de tempo (strsplit); O padrão é ":" * (4) Defina o separador em (1), (2), (3) SetSplit (strDatesplit, strDateTimesplit, strTimesplit); * (5) Defina o ano inicial e térmico SetyearPeriod (IntdateBeg, IntdateEnd) * Descrição: * O formato de data e hora de retorno padrão é o seguinte: 2005-02-02 08:08 */ / /----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- "Altura: 16px; tamanho da fonte: 9pt; cor: branco; borda: 0 sólido #cccccc; cursor: mão; cor de fundo: #2650A6;"; // botões para o ano todo, mês, etc. var s_tiannet_turn = "largura: 28px;" + S_TIANNET_TURN_BASE; // fechar, limpar, etc. estilos de botão var s_tiannet_turn2 = "largura: 22px;" + S_TIANNET_TURN_BASE; // Selecione a caixa suspensa para var s_tiannet_select o ano todo o ano (largura: 64px; display: Nenhum; "; // Selecione a caixa suspensa de mês, hora e minuto var s_tiannet_select2 = "largura: 46px; display: nenhum;"; // Data Seleção Controle Estilo do corpo Var S_TIANNET_BODY = "Largura: 150; cor de fundo:#2650A6; Display: Nenhum; Z-Index: 9998; Posição: Absolute;" + "Border-left: 1 sólido #cccc; top de borda: 1 sólido #ccc; direita de borda: 1 sólido #999999; fundo da borda: 1 sólido #999999;"; // estilo do TD mostrando o dia var s_tiannet_day = "largura: 21px; altura: 20px; colorido de fundo:#d8f0fc; font-size: 10pt;"; // Font Style var s_tiannet_font = "cor:#ffcc00; font-size: 9pt; cursor: hand;"; // Link Style var s_tiannet_link = "Decoração de texto: nenhum; font-size: 9pt; cor:#2650A6;"; // linha horilia var s_tiannet_line = "borda-bottom: 1 sólido #6699cc"; //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- tiannetYearSt = 1950;//Selectable start year var tiannetYearEnd = 2010; // ano final selecionável var tianNetDatEnow = new Date (); var tiannetyear = tianNetDatEnow.getlyear (); // o valor inicial do ano que define variável // o valor inicial do mês que define variável var tianNetday = tianNetDatEnow.getDate (); var tiannethour = 8; // tianNetDatEnow.gethours (); var tianNetMinute = 0; // tianNetDatEnow.getminutes (); var tiannetarrday = nova matriz (42); // matriz que define a data var tianNetDatesplit = "-"; // separador de data var tianNetDateTimesplit = ""; // Data separador var tianNetTimesplit = ":"; // separador de tempo var tianNetOutObject; // objeto que recebe data e hora var Arrtiannethide = new Array (); // O rótulo que é forçado a ser oculto var m_bolshowhour = false; // faz a hora var m_bolshowminute = false; // se deve exibir minutos var m_amonHead = new Array (12); // Defina o número máximo de dias por mês no calendário 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; // ----------------------------------------------------------------- // Se houver um valor na tag, inicialize a data do valor atual var strvalue = tianNetTrim (tianNetOutObject.value); if (strvalue! = "") {tianNetinitDate (strValue); } tianNetpopCalendar (); } // Função de chamada principal do usuário - Selecione a função Data e hora setdayh (obj) {tianNetOutObject = obj; m_bolshowhour = true; // Se houver um valor na tag, a data e a hora serão inicializadas no valor atual var strvalue = tianNetTrim (tianNetOutObject.value); if (strvalue! = "") {tianNetinitDate (strvalue.substring (0,10)); var hour = strvalue.substring (11,13); if (hora <10) tiannethour = hour.substring (1,2); } tianNetpopCalendar (); } // Função de chamada principal do usuário - selecione Data e hora e minuto Setdayhm (obj) {tianNetOutObject = obj; m_bolshowhour = true; m_bolshowminute = true; // Se houver um valor na tag, inicialize a data, hora e minuto até o valor atual var strvalue = tianNetTrim (tianNetOutObject.value); if (strvalue! = "") {tianNetinitDate (strvalue.substring (0,10)); var time = strvalue.substring (11,16); var arr = 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 (); } // Defina a data de início e a data de término da função SetyearPeriod (intdateBeg, intdateEnd) {tianNetyEarst = intdateBeg; tiannetyEarend = intdateEnd; } // Defina o separador de data. O padrão é "-" função setDatesplit (strdatesplit) {tianNetDatesplit = strDatesplit; } // Defina o separador entre a data e a hora. O padrão é "" função setDateTimesplit (strDatETimesplit) {tianNetDatETimesplit = strDatETimesplit; } // Defina o separador de tempo. O padrão é ":" function Settimesplit (strTimesplit) {tianNettimesplit = strTimesplit; } // Defina a função separadora Setsplit (strDatesplit, strDatETimesplit, strTimesplit) {tianNetDatesplit (strDatesplit); tianNetDatETimesplit (strdatetimesplit); tiannettimesplit (strTimesplit); tiannettimesplit (strTimesplit); } // Defina a data padrão. O formato é: aaaa-mm-dd SetDefaultDate (strdate) {tiannetyear = strdate.substring (0,4); tiannetMonth = strdate.substring (5,7); tianNetday = strdate.substring (8,10); } // Defina o tempo padrão. O formato é: hh24: mi função setDefaultTime (strtime) {tiannethour = strtime.substring (0,2); tiannetminute = strtime.substring (3,5); } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ style = "'+s_tiannet_body+'" style = "Este controle de seleção de calendário é aprimorado pelo TianNet com base na experiência das gerações 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 ();"> ano </span> '); document.write ('<select id = "Seltianyear" style = "' '+s_tiannet_select+'" Author = "Tiannet" '+' onchange = "tiannetyear = this.value; tianNetSetday (tianNearearearearing, tiannetmonth); 'this.style.display =/' none/'; ">'); for (var i = tiannetyearst; i <= tiannetyEarend; i ++) {document.writeln ('<opção value = "' + i + '">' + i + 'ano </pption>'); } document.write ('</leclect>'); document.write ('<span id = "tiannetmonthhead" autor = "tiannet" style = "'+s_tiannet_font+''" '+' onclick = "spanMonthcevent ();"> mês </span> '); document.write ('<select id = "seltianmonth" style = "' '+s_tiannet_select2+'" Author = "tiannet" '+' onchange = "tiannetmonth = this.value; tianNetMONDOMNDERDY (tiannetry, tiannetmond); 'this.style.display =/' none/'; ">'); para (var i = 1; i <= 12; i ++) {document.writeln ('<opção value = "' + i + '">' + i + '' mês </pption> '); } document.write ('</leclect>'); //document.write ('</div>'); //document.write('<div align = "Center" id = "DivtianNETTIMETEXT" AUTOR = "TIANNET"> '); document.write ('<span id = "tiannethourhead" autor = "tiannet" style = "'+s_tiannet_font+'display: none;"'+'OnClick = "Sp3Hourcevent ();"> quando </span>'); document.write ('<select id = "Seltianhour" style = "' '+s_tiannet_select2+' Display: None;" Author = "Tiannet" '+' OnChange = "TianNethour = this.value; TianNetwriteHead (); 'this.style.display =/' none/'; ">'); for (var i = 0; i <= 23; i ++) {document.writeln ('<opção value = "' + i + '">' + i + 'time </pption>'); } document.write ('</leclect>'); document.write ('<span id = "tiannetminutehead" autor = "tiannet" style = "'+s_tiannet_font+'display: none;"'+'onclick = "spanMinutecevent ();"> ponto </span>); document.write ('<select id = "SeltianMinute" style = "' '+s_tiannet_select2+' Display: None;" Author = "TianNet" '+' OnChange = "TianNetminUte = thOnVyled; 'this.style.display =/' none/'; ">'); for (var i = 0; i <= 59; i ++) {document.writeln ('<opção value = "' + i + '">' + i + '' ponto </pption> '); } document.write ('</leclect>'); document.write ('</div>'); // Saída de um documento de linha horizontal.Write ('<div style = "'+s_tiannet_line+'"> </div>'); document.write ('<div align = "Center" id = "Divtiannetnurn" style = "borda: 0;" autor = "tiannet">'); document.write ('<input type = "button" style = "'+s_tiannet_turn+'" value = "ano ↑" onclick = "tianNetPrevyear ();">'); document.write ('<input type = "button" style = "'+s_tiannet_turn+'" value = "ano ↓" onclick = "tianNetNextyear ();">'); document.write ('<input type = "button" style = "'+s_tiannet_turn+'" value = "ano ↓" onclick = "tianNetNextyear ();">'); document.write ('<input type = "button" style = "'+s_tiannet_turn+'" value = "mês ↑" onclick = "tiannetprevmonth ();">'); document.write ('<input type = "button" style = "'+s_tiannet_turn+'" value = "mês ↓" onclick = "tianNetNextmonth ();">'); document.write ('</div>'); // Saída de um documento de linha horizontal.Write ('<div style = "'+s_tiannet_line+'"> </div>'); document.write ('<borda da tabela = 0 CellSpacing = 0 CellPadding = 0 BGCOLOR = WHITE ONSELECTSTART = "Return false">'); Document.Write ('<tr Style = "Background-Color:#2650A6; font-size: 10pt; cor: branco; altura: 22px;" autor = "tiannet">'); for (var i = 0; i <weekName.length; i ++) {// Output Weekday Document.Write ('<td align = "Center" Author = "Tiannet">' + WeekName [i] + '</td>'); } document.write ('</tr>'); document.write ('</ table>'); // Selecione o documento do dia da saída.WRITE ('<Tabela Border = 0 CellPacing = 1 CellPadding = 0 BGColor = White OneSelectStart = "Return false">'); var n = 0; for (var i = 0; i <5; i ++) {document.write ('<tr align = central id = "trtianNetday' + i + '">'); para (var j = 0; j <7; j ++) {document.write ('<td align = "Center" id = "tdtianNetday' ' + n +'" ' +' onclick = "tianNetday = this.innertext; tiannetvalue (true); n ++; } document.write ('<tr align = central id = "trtianNetday5">'); document.write ('<td align = "Center" id = "tdtianNetday35" OnClick = "tianNetday = this.innerText; tianNetSetValue (true);"' + 'style = "' + s_tiannet_day + '"> </td>'); document.write ('<td align = "Center" id = "tdtianNetday36" OnClick = "tianNetday = this.innerText; tianNetSetValue (true);"' + 'style = "' + s_tiannet_day + '"> </td>'); document.write ('<td align = "direita" colspan = "5"> <a href = "javascript: tiannetclear ();" style = "' + s_tiannet_link + '"> clear </a>' + '<a href = "javascript: tianNethidEConTrol (AA> '"> Feche </a>' + '<a href =" javascript: tiannetValue (true); "style ="' + s_tiannet_link + '"> ok </a>' + '</td>'); document.write ('</tr>'); document.write ('</ table>'); document.write ('</div>'); //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- spanYearCEvent(){ hideElementsById(new Array ("Seltianyear", "Tiannetmonthhead"), falso); if (m_bolshowhour) hidelementsById (nova matriz ("tiannethourhead"), falsa); if (m_bolshowminute) hidelementsById (new Array ("tianNetminutehead"), false); HidelementsById (New Array ("TiannetyEarhead", "Seltianmonth", "Seltianhour", "Seltianminute"), verdadeiro); } // Clique na tag do mês para responder a função spanmonthcevent () {hidelementsById (nova matriz ("Seltianmonth", "tiannetyearhead"), false); if (m_bolshowhour) hidelementsById (nova matriz ("tiannethourhead"), falsa); if (m_bolshowminute) hidelementsById (new Array ("tianNetminutehead"), false); HidelementsById (New Array ("Tiannetmonthhead", "Seltianyear", "Seltianhour", "Seltianminute"), verdadeiro); } // Clique na função de resposta da tag span tag hour spranhourcevent () {hidelementsById (new Array ("tiannetyearhead", "tiannetmonthhead"), false); if (m_bolshowhour) hidelementsById (nova matriz ("seltianhour"), false); if (m_bolshowminute) hidelementsById (new Array ("tianNetminutehead"), false); HidelementsById (New Array ("Tiannethourhead", "Seltianyear", "Seltianmonth", "Seltianminute"), verdadeiro); } // Clique na função de resposta de tag minuto spanMinUteCevent () {hidelementsById (New Array ("TiannetyEarhead", "Tiannetmonthhead"), false); if (m_bolshowhour) hidelementsById (nova matriz ("tiannethourhead"), falsa); if (m_bolshowminute) hidelementsById (new Array ("SeltianMinute"), false); HidelementsById (New Array ("Tiannetminutehead", "Seltianyear", "SeltianMonth", "SeltiaHour"), verdadeiro); } // Ocultar ou exibir a função HidelementsById (arrid, Bolhide) {var strDisplay = ""; if (Bolhide) strDisplay = "nenhum"; for (var i = 0; i <arrid.length; i ++) {var obj = document.getElementById (arrid [i]); obj.style.display = strDisplay; }} // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- if ((mês == 2) && ispinyear (ano)) c ++; retornar c; } // Redefina o dia atual. Principalmente, para impedir que o dia atual seja maior que o dia máximo do mês, quando o ano é revertido ou o mês é anulado. function setRealdayCount () {if (tiannetday> getMonthCount (tiannetyear, tiannetmonth)) {// se o dia atual for maior que o dia máximo do mês, o dia máximo do mês for tomado. TianNetday = GetMonthCount (Tiannetyear, Tiannetmonth); }} // Adicione zero antes da função de dígitos únicos addZero (value) {if (value <10) {value = "0" + value; } retornar valor; } // Recuperar a função de espaço tianNetTrim (str) {return str.replace (/(^/s*) | (/s*$)/g, ""); } // Crie uma função de opção CreateOption (objSelect, valor, texto) {var option = document.createElement ("option"); option.value = value; option.Text = text; objSelect.options.add (opção); } // Função do ano para a frente Função tianNetPrevyear () {if (tiannetyear> 999 && tiannetyear <10000) {tiannetyear--;} else {alert ("ano fora do alcance (1000-9999)!); // Se o ano for menor que o ano mínimo permitido, crie a opção correspondente se (tiannetyear <tiannetyearst) {tiannetyearst = tiannetyear; CreateOption (document.all.seltianyear, tiannetyear, tiannetyear + "ano"); } checkSelect (document.all.seltianyear, tiannetyear, tiannetyear); tianNetWriteHead (); } // função do ano flip tianNetNextyear () {if (tiannetyear> 999 && tiannetyear <10000) {tiannetyear ++;} else {alert ("ano fora do alcance (1000-9999)!"); retornar;} TianNetSetday (Tiannetyear, Tiannetmonth); // Se o ano exceder o ano máximo permitido, crie a opção correspondente se (tiannetyear> tiannetyEarend) {tiannetyearend = tiannetyear; CreateOption (document.all.seltianyear, tiannetyear, tiannetyear + "ano"); } checkSelect (document.all.seltianyear, tiannetyear, tiannetyear); tianNetWriteHead (); } // Selecione hoje function tianNetToday () {tiannetyear = tianNetDatEnow.getlyear (); tianNetMONTH = tianNetDatEnow.getMonth ()+1; tianNetday = tianNetDatEnow.getDate (); TianNetSetValue (verdadeiro); // TianNetSetday (Tiannetyear, Tiannetmonth); // selectObject (); } // Siga a função do mês do mês tianNetPrevMmonth () {if (tianNetMonth> 1) {tianNetmonth-} else {tiannetyear-; tiannetmonth = 12;} tiannetday (tiannearear, tiannemoMonth); CheckSelect (document.all.seltianmonth, tiannetmonth); tianNetWriteHead (); } // Siga a função do mês tianNetNextMonth () {if (tianNetmonth == 12) {tiannetyear ++; tianNetmonth = 1} else {tiannetmonth ++} tiannetsetday (tiannearearear, tiannetmonth); CheckSelect (document.all.seltianmonth, tiannetmonth); tianNetWriteHead (); } // Escreva ano, mês, tempo, minuto e outros dados na função de tag span tianNetwritehead () {document.all.tiannetyearhead.innerText = tiannetyear + "ano"; document.all.tiannetmonthhead.innerText = tiannetmonth + "mês"; if (m_bolshowhour) document.all.tiannethourhead.innertext = "" + tiannethour + "time"; if (m_bolshowminute) document.all.tiannetminutehead.innerText = tiannetminute + "minutos"; TianNetSetValue (false); // atribui valores à caixa de texto, mas não oculte esse controle} // Defina a função do dia de exibição tianNetSday (yy, mm) {setRealdayCount (); // Defina o dia real do mês tiannetwriteHead (); var strdateFont1 = "", strdateFont2 = "" // Treine o estilo da data de exibição para (var i = 0; i <37; i ++) {tiannetarrday [i] = ""}; // limpe todo o conteúdo da caixa de exibição var day1 = 1; var Firstday = New Date (yy, mm-1,1) .Getday (); // Dia da semana do primeiro dia de um certo mês para (var i = primeiro dia; dia1 <getMonthCount (yy, mm) +1; i ++) {tiannetarrDay [i] = dia1; dia1 ++; } // Se o valor da primeira célula usado para exibir a última linha do dia estiver vazio, oculte a linha inteira. // if (tiannetarrday [35] == "") {// document.all.trtiannetday5.style.display = "nenhum"; //} else {// document.all.trtiannetday5.style.display = ""; //} para (var i = 0; i <37; i ++) {var da = avaliar ("document.all.tdtianNetday"+i) // escrevendo o acordo de data e semana do novo mês se (tianneTarrday 1 [i]! strdateFont1 = "<font color =#f0000>" strDateFont2 = "</font>"} else {strDateFont1 = ""; strdateFont2 = ""} da.innerhtml = strdatefont1 + tiannetarrday [i] + strdateFont2; // Se for o dia selecionado atualmente, altere a cor if (tiannetarrday [i] == tianNetday) {da.style.backgroundcolor = "#cccccc"; } else {da.style.backgroundcolor = "#efef"; } da.style.cursor = "hand"} else {da.innerhtml = ""; da.style.backgroundcolor = ""; da.style.cursor = "padrão"}}} // termina para tiannetsetValue (false); // atribuir um valor para a caixa de texto, mas não ocultar este tanNeTValue (FALSE); checkSelect (objSelect, selectValue) {var count = parseInt (objselect.length); if (selectValue <10 && SElectValue.toString (). Length == 2) {selectValue = selectValue.substring (1,2); } for (var i = 0; i <count; i ++) {if (objSelect.options [i] .Value == selectValue) {objSelect.SelectedIndex = i; quebrar; }} // para} // Selecione a caixa suspensa SelectObject () {// Se o ano for menor que o ano mínimo permitido, crie a opção correspondente se (tiannetyear <tiannetyearst) {para (var i = tiannearear; i <tiannetys; i ++) {createOption (document.lsellel; } tiannetyearst = tiannetyear; } // Se o ano exceder o ano máximo permitido, crie a opção correspondente se (tiannetyear> tiannetyEarend) {for (var i = tiannetyEarend + 1; i <= tiannetyear; i ++) {createOption (document.all.seltianyear, i, i + "ano");); } 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); } // Atribua um valor ao controle que aceita data e hora // parâmetros Bolhidecontrol - Se deve ocultar a função de controle tiannetValue (bolhidecontrol) {var value = ""; if (! retornar; } var mm = tianNetMonth; Var Day = TianNetday; if (mm <10 && mm.toString (). comprimento == 1) mm = "0" + mm; if (dia <10 && day.tostring (). comprimento == 1) dia = "0" + dia; Valor = tiannetyear + tianNetDatesplit + mm + tianNetDatesplit + dia; if (m_bolshowhour) {var hour = tiannethour; if (hora <10 && hour.toString (). comprimento == 1) hora = "0" + hora; valor + = tianNetDateTimesplit + hora; } if (m_bolshowminute) {var minute = tianNetminute; if (minuto <10 && minute.toString (). comprimento == 1) minuto = "0" + minuto; valor + = tianNettimesplit + minuto; } tianNetOutObject.value = value; //document.all.divtiannetdate.style.display = "nenhum"; if (bolhidecontrol) {tiannethidecontrol (); }} // exibe tempo função showTime () {if (! M_bolshowhour && m_bolshowminute) {alert ("se você deseja selecionar minutos, deve ser capaz de selecionar horas!"); retornar; } hidelementsById (New Array ("Tiannethourhead", "SeltiaHour", "TianNetminutehead", "Seltianminute"), verdadeiro); if (m_bolshowhour) {// mostre horas de esconderijo (new Array ("tiannethourhead"), false); } if (m_bolshowMinute) {// mostra minutos hidelementsById (new Array ("tiannethourhead"), false); } if (m_bolshowMinute) {// Mostra minutos HidelementsById (New Array ("TianNetMinuteHead"), false); }} // O controle de seleção do calendário aparece para permitir que o usuário selecione a função tianNetpopCalendar () {// Ocultar a caixa suspensa para exibir o esconderijo da cabeça correspondente (new Array ("Seltianyear", "SeltianMonth", "Seltianhour",, "SeltianminUte"); HidelementsById (New Array ("TiannetyEarhead", "Tiannetmonthhead", "TiannetMinutehead"), false); TianNetSetday (Tiannetyear, Tiannetmonth); tianNetWriteHead (); altura de começar(); var dads = document.all.divtianNetdate.style; var ix, iy; var h = document.all.divtianNetdate.offsetHeight; var w = document.all.divtianNetDate.OffSetWidth; // calcule a esquerda if (window.event.x + h> document.body.offsetWidth - 10) ix = window.event.x - h - 5; senão ix = window.event.x + 5; if (ix <0) ix = 0; // calcule o top iy = window.event.y; if (window.event.y + w> document.body.offSethEight - 10) iy = document.body.scrolltop + document.body.offsetheight - w - 5; senão iy = document.body.scrolltop + window.event.y + 5; if (iy <0) iy = 0; papai.left = ix; papai.top = iy; tiannetshowControl (); selectObject (); } // Ocultar controle do calendário (mostrando as tags ocultas forçadas ao mesmo tempo) função tiannethidecontrol () {document.all.divtiannetdate.style.display = "nenhum"; tianNetShowObject (); Arrtiannethide = new Array (); // Limpe o objeto de tag oculto} // Mostra o controle do calendário (oculte as tags obscurecidas ao mesmo tempo) função tiannetshowcontrol () {document.all.divtiannetdate.style.display = "";; tiannethideObject ("selecione"); tiannethideObject ("objeto"); } // Ocultar tags de acordo com o nome da tag. Se a seleção do controle for bloqueada, a função do objeto tiannethideObject (strTagName) {x = document.all.divtianNetdate.OffSetLeft; y = document.all.divtianNetdate.OffSettop; h = document.all.divtianNetdate.offsetHight; 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; // Obtenha as coordenadas relativas do elemento para a etiqueta corporal var objleft = obj.offsetleft; var objtop = obj.offSettop; var objHeight = obj.offSethEight; var objwidth = obj.offsetWidth; var objParent = obj.OffSetParent; while (objParent.tagname.TOUPPERCASE ()! = "Body") {objleft += objparent.offsetleft; objtop += objParent.OffSettop; objparent = objParent.OffsetParent; } // alert ("extremidade esquerda do controle:" + x + "selecione a extremidade esquerda" + (objleft + objwidth) + "parte inferior do controle:" + (y + h) + "selecione alto:" + objtop); var bolhide = true; if (obj.style.display == "nenhum" || obj.style.visibility == "hidden" || obj.getAttribute ("autor") == "tiannet") {// se a tag em si estiver oculta, não precisará mais ser escondida. Se for uma caixa suspensa no controle, ela não precisa ser oculta. Bolhide = false; } if (((objleft + objwidth)> x && (y + h + 20)> objtop && (objtop + objHeight)> y && objleft <(x + w)) && bolhide) {//arrtiannethide.push 13; obj.style.visibility = "Hidden"; }}} // Mostrar função de tag oculta tianNetShowObject () {for (var i = 0; i <arrtiannethide.length; i ++) {// alert (Arrtiannethide [i]); Arrtiannethide [i] .style.visibility = ""; }} // Data de inicialização. função tianNetinitDate (strdate) {var arr = strdate.split (tianNetDatesplit); tiannetyear = arr [0]; tiannetmonth = arr [1]; TianNetday = arr [2]; } // função limpa tiannetClear () {tianNetOutObject.value = ""; tiannethidEControl (); } // Feche o controle ao clicar em qualquer documento de função.OnClick () {with (window.event.srcelement) {if (tagname! = "Input" && getAttribute ("autor")! = "Tiannet") tiannethideControl (); }} // Pressione a tecla ESC para fechar o documento da função de controle.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 "," Resumo dos algoritmos e técnicas de travessia de JavaScript "e" Resumo do uso de operações matemáticas de JavaScript "
Espero que este artigo seja útil para a programação JavaScript de todos.