Cet article décrit le bel effet de sélection de temps de temps de JS. Partagez-le pour votre référence, comme suit:
Pièce de code HTML:
<html> <script linguisse = javascript src = "dataone.js"> </cript> <table align = "Center"> <tr> <td> <body> (1) Sélectionner la date unique onClick = "setdayh (this);"> <br/> (3) Sélectionnez la date et l'heure et la minute <entrée type = "text" name = "datehm" readonly onclick = "setdayhm (this);"> </ body> </td> </tr> </ table> </html>
Code DataOne.js:
/ *** Méthode d'utilisation: * (1) Sélectionnez uniquement la date <entrée type = "text" name = "date" readonly onclick = "setday (this);"> * (2) sélectionnez la date et l'heure <entrée type = "text" name = "dateh" readonly onclick = "setdayh (this);"> * (3) SELECT DATE and Hour <Input type = "text" nom = "datehm" lecture " onClick = "setdayHm (this);"> * Méthode pour régler les paramètres * (1) Définissez le séparateur de date setDatesplit (strSplit); La valeur par défaut est "-" * (2) Définir le séparateur entre la date et l'heure SetDatetimesplit (strSplit); La valeur par défaut est "" * (3) Définir le séparateur de temps SettheSplit (strSplit); La valeur par défaut est ":" * (4) Définissez le séparateur dans (1), (2), (3) setSplit (strdatesplit, strdatetimesplit, strtimesplit); * (5) Définissez l'année de début et de fin SetyEarperiod (IntDateBeg, IntDateend) * Description: * Le format de date et d'heure retourné par défaut est le suivant: 2005-02-02 08:08 * / // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- "Hauteur: 16px; taille de police: 9pt; couleur: blanc; bordure: 0 solide #cccccc; curseur: main; fond-couleur: # 2650a6;"; // boutons pour toute l'année, le mois, etc. var s_tiannet_turn = "width: 28px;" + s_tiannet_turn_base; // Fermer, claire, etc. Styles de bouton var s_tiannet_turn2 = "width: 22px;" + s_tiannet_turn_base; // Sélectionnez la boîte déroulante pour Var S_Tiannet_Select = "Width: 64PX; Affichage: Aucun;"; // Sélectionnez la boîte déroulante de mois, heure et minute var s_tiannet_select2 = "largeur: 46px; affichage: aucun;"; // Date Sélection Contrôle Style Body Var S_Tiannet_Body = "Width: 150; Background-Color: # 2650A6; Affichage: Aucun; Z-Index: 9998; Position: Absolute;" + "Border-Left: 1 solide #cccc; border-top: 1 solide #cccc; border-right: 1 solide # 999999; border-bottom: 1 solide # 999999;"; // style du TD montrant le jour var s_tiannet_day = "width: 21px; hauteur: 20px; background-color: # d8f0fc; font-size: 10pt;"; // Style de police var s_tiannet_font = "Color: # ffcc00; font-size: 9pt; curseur: hand;"; // Style de lien var s_tiannet_link = "Text-Decoration: Aucun; Font-Size: 9pt; Color: # 2650A6;"; // HORINGLY LINE VAR S_TIANNET_LINE = "Border-Bottom: 1 Solid # 6699CC"; //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- tiannetYearSt = 1950;//Selectable start year var tiannetYearEnd = 2010; // Var TiannetDatenow = NOUVEAU () de l'année sélectionnable Var TiannetDatenow = new Date (); var tiannetyear = tiannetDatenow.getlyar (); // La valeur initiale de la variable de définition de l'année var tiannetMonth = TiannetDatenow.getMonth () + 1; // La valeur initiale du mois de définition de la variable var tiannetday = tiannetdatenow.getDate (); var tiannethour = 8; // tiannetDatenow.Gethours (); var tiannetMinute = 0; // tiannetDatenow.getMinutes (); var TiannetArday = nouveau tableau (42); // Array qui définit la date var tiannetdatesplit = "-"; // Date Sépréteur var tiannetDatetimetimeSplit = ""; // Date Sépréteur var tiannettimesplit = ":"; // Time séparateur var tiannetoutObject; // Objet qui reçoit la date et l'heure var arrtiannetHide = new Array (); // l'étiquette qui est forcée d'être cachée var m_bolshowhour = false; // fait l'heure var m_bolshowMinute = false; // à afficher les minutes var m_amonhead = new Array (12); // Définissez le nombre maximum de jours par mois dans le calendrier grégorien 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; // ------------------------------------------------------------------------- /// Fonction d'appel principal utilisateur - Sélectionnez la fonction de date uniquement Setday (OBJ) {TiannetOutObject = OBJ; // S'il y a une valeur dans la balise, initialisez la date à la valeur actuelle var strvalue = tiannettrim (tiannetoutObject.Value); if (strValue! = "") {tiannetInitDate (strValue); } TiannetPopCalendar (); } // Fonction d'appel principal de l'utilisateur - Sélectionner la fonction Date et Hour SetdayH (OBJ) {TiannetOutObject = OBJ; m_bolShowHour = true; // s'il y a une valeur dans la balise, la date et l'heure sont initialisées à la valeur actuelle var strvalue = tiannettrim (tiannetObject.Value); if (strValue! = "") {tiannetInitDate (strvalue.substring (0,10)); var hour = strvalue.substring (11,13); if (heure <10) tiannethour = hour.substring (1,2); } TiannetPopCalendar (); } // Fonction d'appel principal de l'utilisateur - Sélectionner la fonction et la fonction heure et minute SetdayHm (OBJ) {TiannetOutObject = OBJ; m_bolShowHour = true; m_bolShowMinute = true; // s'il y a une valeur dans la balise, initialisez la date, l'heure et la minute à la valeur actuelle var strvalue = tiannetrim (tiannetObject.Value); if (strValue! = "") {tiannetInitDate (strvalue.substring (0,10)); var time = strvalue.substring (11,16); var arr = time.split (TiannettimetimeSplit); tiannethour = arr [0]; tiannetMinute = arr [1]; if (tiannethour <10) tiannethour = tiannethour.substring (1,2); if (tiannetMinute <10) tiannetMinute = tiannetMinute.Substring (1,2); } TiannetPopCalendar (); } // Définissez la fonction de date de début et de fin de la date SetyEarperiod (IntDateBeg, IntDateend) {TianNetyAtSt = IntDateBeg; TianNetyEarend = intDateend; } // Définissez le séparateur de date. La valeur par défaut est "-" fonction setDatesplit (strdatesplit) {tiannetdatesplit = strdatesplit; } // Définissez le séparateur entre la date et l'heure. La valeur par défaut est "" function setDatetimeSplit (strdatetimesplit) {tiannetDateTimesplit = strdatetimesplit; } // Définissez le séparateur de temps. La valeur par défaut est ":" Function Settmesplit (strtimesplit) {Tiannettimesplit = strtimesplit; } // Définissez la fonction de séparateur setSplit (strdatesplit, strDatetimesplit, strtimesplit) {tiannetDatesplit (strdatesplit); TiannetDatetimesplit (strdatetimesplit); Tiannettimesplit (Strtimesplit); Tiannettimesplit (Strtimesplit); } // Définissez la date par défaut. Le format est: yyyy-mm-dd function setDefaultDate (strdate) {tiannetyear = strdate.substring (0,4); TiannetMonth = Strdate.Substring (5,7); tiannetday = strdate.substring (8,10); } // Définissez l'heure par défaut. Le format est: HH24: la fonction mi SetDefaultTime (strtime) {tiannethour = strtime.substring (0,2); tiannetMinute = strtime.substring (3,5); } // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- style = "'+ s_tiannet_body +'" style = "Ce contrôle de sélection du calendrier est amélioré par Tiannet en fonction de l'expérience des générations précédentes!"> '); Document.Write ('<div align = "Center" id = "DivtianNetDateText" Author = "Tiannet" style = "Padding-top: 2px;">'); document.write ('<span id = "tiannetyearhead" auteur = "tiannet" style = "' + s_tiannet_font + '"' + 'onclick = "spanyearcevent ();"> année </span>'); document.write ('<select id = "seltianyear" style = "' + s_tiannet_select + '" auteur = "tiannet"' + 'onchange = "tiannetyear = this.value; tiannetsetday (tiannetyear, tiannetMonth); document.all.tiannetyead.style.display = /'! 'this.style.display = /' Aucun / '; ">'); for (var i = tiannetyAstSt; i <= tiannetyEarend; i ++) {document.writeln ('<option value = "' + i + '">' + i + 'année </opoption>'); } document.write ('</lect>'); Document.Write ('<span id = "tiannetMonThhead" Author = "tiannet" style = "' + s_tiannet_font + '"' + 'onclick = "spanmonthcevent ();"> mois </span>'); document.write ('<select id = "seltianmonth" style = "' + s_tiannet_select2 + '" auteur = "tiannet"' + 'onchange = "tiannetMonth = this.value; tiannetssetday (tiannetyear, tiannetMonth); document.all.tiannetmEhead.style.display = /' '' +; 'this.style.display = /' Aucun / '; ">'); pour (var i = 1; i <= 12; i ++) {document.writeln ('<option value = "' + i + '">' + i + 'mois </ option>'); } document.write ('</lect>'); //Document.Write ('</div>'); //Document.write('<Div align = "Center" id = "divtianneTtimeText" Author = "Tiannet"> '); Document.Write ('<span id = "TianneThourHead" Author = "tiannet" style = "' + s_tiannet_font + 'affiche: aucun;" +' onClick = "spanHourcevent ();"> quand </span> '); document.write ('<select id = "seltianhour" style = "' + s_tiannet_select2 + 'affichage: non;" auteur = "tiannet"' + 'onchange = "tiannethour = this.value; tiannetwritehead (); document.all.tiannethourhead.style.display = /' / '; 'this.style.display = /' Aucun / '; ">'); pour (var i = 0; i <= 23; i ++) {document.writeln ('<option value = "' + i + '">' + i + 'time </ option>'); } document.write ('</lect>'); Document.Write ('<span id = "tiannetMinuteHead" Author = "tiannet" style = "' + s_tiannet_font + 'affiche: aucun;" +' onClick = "spanminutecevent ();"> point </span> '); document.write ('<select id = "seltianMinute" style = "' + s_tiannet_select2 + 'affiche: non;" auteur = "tiannet"' + 'onchange = "tiannetMinUte = this.value; tiannetwritehead (); document.all.tiannetMinutehead.style.display = /' / '; 'this.style.display = /' Aucun / '; ">'); pour (var i = 0; i <= 59; i ++) {document.writeln ('<option value = "' + i + '">' + i + 'point </opoption>'); } document.write ('</lect>'); Document.Write ('</div>'); // Sortie d'un document de ligne horizontal.write ('<div style = "' + s_tiannet_line + '"> </div>'); document.write ('<div align = "Center" id = "divtiannetturn" style = "border: 0;" auteur = "tiannet">'); document.write ('<input type = "Button" style = "' + s_tiannet_turn + '" value = "année ↑" onclick = "tiannetprevyear ();">'); document.write ('<input type = "Button" style = "' + s_tiannet_turn + '" value = "année ↓" onClick = "tiannetNExTyear ();">'); document.write ('<input type = "Button" style = "' + s_tiannet_turn + '" value = "année ↓" onClick = "tiannetNExTyear ();">'); document.write ('<input type = "Button" style = "' + s_tiannet_turn + '" value = "mois ↑" onclick = "tiannetprevmonth ();">'); document.write ('<input type = "Button" style = "' + s_tiannet_turn + '" value = "mois ↓" onclick = "tiannetnextmonth ();">'); Document.Write ('</div>'); // Sortie d'un document de ligne horizontal.write ('<div style = "' + s_tiannet_line + '"> </div>'); Document.Write ('<Table Border = 0 CELLSPACINE = 0 CELLPADDING = 0 BGCOLOR = WHITE ONSELECTSTART = "RETOUR FAUX">'); Document.Write ('<tr style = "Background-Color: # 2650A6; FONT-Size: 10pt; Color: White; Height: 22px;" Author = "Tiannet">'); for (var i = 0; i <weekName.length; i ++) {// output weekday document.write ('<td align = "Center" auteur = "tiannet">' + weekname [i] + '</td>'); } document.write ('</tr>'); Document.Write ('</ Table>'); // select of Output Day Document.Write ('<Table Border = 0 CellPacing = 1 CellPadding = 0 bgColor = blanc onSelectStart = "return false">'); var n = 0; pour (var i = 0; i <5; i ++) {document.write ('<tr align = central id = "trtiannetday' + i + '">'); pour (var j = 0; j <7; j ++) {document.write ('<td align = "Center" id = "tdtiannetday' + n + '"' + 'onclick = "tiannetday = this.innertext; tiannetSetValue (true);"' + 'style = "' + s_tiannet_day + '"> </td>'); 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 = "droit" colspan = "5"> <a href = "javascript: tiannetClear ();" style = "' + s_tiannet_link + '"> Clear </a>' + '<a href = "javascript: tiannetheDeControl ();" style = "' '+ s_tiannet_link +"> ". '<a href = "javascript: tiannetSetValue (true);" Style = "' + s_tiannet_link + '"> ok </a>' + '</ td>'); document.write ('</tr>'); Document.Write ('</ Table>'); Document.Write ('</div>'); // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Array ("seltianyear", "tiannetmonthhead"), false); if (m_bolshowhour) hideelementsById (nouveau array ("tiannethourhead"), false); if (m_bolShowMinute) hideelementsById (nouveau array ("tiannetMinuteHead"), false); hideelementsbyid (New Array ("TiannetyEarhead", "seltianmonth", "seltianhour", "seltianMinute"), true); } // Cliquez sur la balise SPAN MOIS pour répondre à la fonction spanmonthcevent () {hideelementsById (new Array ("seltianMonth", "tiannetyearhead"), false); if (m_bolshowhour) hideelementsById (nouveau array ("tiannethourhead"), false); if (m_bolShowMinute) hideelementsById (nouveau array ("tiannetMinuteHead"), false); HideelementsByid (New Array ("TiannetMonthhead", "Seltianyear", "Seltianhour", "seltianMinute"), true); } // Cliquez sur la fonction de réponse de la balise Hour Span SpanHourcevent () {HideelementsById (nouveau Array ("TianNetyEarhead", "TiannetMonThhead"), false); if (m_bolShowHour) hideelementsById (nouveau array ("seltianhour"), false); if (m_bolShowMinute) hideelementsById (nouveau array ("tiannetMinuteHead"), false); Hideelementsbyid (New Array ("Tiannethourhead", "Seltianyear", "Seltianmonth", "SeltianMinute"), True); } // Cliquez sur la fonction de réponse de la balise Span Minute SpanMinUteCevent () {HideelementsById (nouveau Array ("TianNetyEahead", "TiannetMonThhead"), false); if (m_bolshowhour) hideelementsById (nouveau array ("tiannethourhead"), false); if (m_bolShowMinute) hideelementsById (nouveau array ("seltianMinute"), false); HideelementsByid (New Array ("TiannetMinutehead", "Seltianyear", "Seltianmonth", "Seltianhour"), true); } // masquer ou afficher la fonction tag hideelementsById (arrid, bolhide) {var strDisplay = ""; if (bolhide) strDisplay = "Aucun"; for (var i = 0; i <arrid.length; i ++) {var obj = document.getElementById (Arrid [i]); obj.style.display = strDisplay; }} // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- if ((mois == 2) && ispinyear (année)) c ++; Retour C; } // Réinitialisez le jour en cours. Principalement pour empêcher le jour en cours d'être supérieur au jour maximum du mois où l'année est annulée ou le mois est annulé. fonction setRealDayCount () {if (tiannetday> getMonthCount (Tiannetyear, tiannetMonth)) {// Si le jour en cours est supérieur au jour maximum du mois, alors le jour maximum du mois est pris. tiannetday = getMonthCount (Tiannetyear, tiannetMonth); }} // ajouter zéro avant la fonction à un seul chiffre addzero (valeur) {if (value <10) {value = "0" + value; } RETOUR-valeur; } // Récupérer la fonction d'espace tiannettrim (str) {return str.replace (/ (^ / s *) | (/ s * $) / g, ""); } // Créer une fonction d'option createOption (objSelect, valeur, texte) {var option = document.createElement ("option"); option.value = valeur; option.text = text; objSelect.options.add (option); } // Flip Avance Year Fonction tiannetPrevyear () {if (TianNetyEar> 999 && tiannetyear <10000) {tiannetyear----;} else {alert ("Year Out of Range (1000-9999)!");} TiannetSetday (Tiannetyear, TiannetMonth); // Si l'année est inférieure à l'année minimale autorisée, créez l'option correspondante si (Tiannetyear <TiannetyeStSt) {TianNetyeStSt = TianNetyEar; createOption (document.all.seltianyear, tiannetyear, tiannetyear + "année"); } CheckSelect (document.all.seltianyear, tiannetyear, tiannetyear); tiannetwritehead (); } // flip annue function tiannetnextyear () {if (tiannetyear> 999 && tiannetyear <10000) {tiannetyear ++;} else {alert ("année hors de portée (1000-9999)!"); return;} TianNetSetday (Tiannetyear, tiannetMonth); // Si l'année dépasse l'année maximale autorisée, créez l'option correspondante if (TiannetyEar> TianNetyEarend) {TianNetyEarend = TianNetyEar; createOption (document.all.seltianyear, tiannetyear, tiannetyear + "année"); } CheckSelect (document.all.seltianyear, tiannetyear, tiannetyear); tiannetwritehead (); } // Sélectionner la fonction aujourd'hui TianNetToday () {TianNetyEar = TiannetDatenow.getlyar (); TiannetMonth = tiannetDatenow.getMonth () + 1; tiannetday = tiannetdatenow.getDate (); TianNetSetValue (vrai); // TianNetSetday (Tiannetyear, tiannetmonth); // selectObject (); } // Suivez la fonction du mois du mois TiannetPrevMonth () {if (tiannetMonth> 1) {tiannetMonth -} else {tiannetyear -; tiannetMonth = 12;} TianNetSetday (Tiannetyear, TiannetMonth); ChecksElect (document.all.seltianmonth, tiannetmonth); tiannetwritehead (); } // Suivez la fonction du mois TiannetNextMonth () {if (tiannetMonth == 12) {TianNetyEar ++; TiannetMonth = 1} else {TiannetMonth ++} TianNetSetday (TiannetyEar, TiannetMonth); ChecksElect (document.all.seltianmonth, tiannetmonth); tiannetwritehead (); } // Écriture année, mois, heure, minute et autres données dans la fonction de tag de span tiannetwritehead () {document.all.tiannetyearhead.innertext = tiannetyar + "année"; Document.all.tiannetMonthhead.InnerText = TiannetMonth + "Mois"; if (m_bolshowhour) document.all.tiannethourhead.innertext = "" + tiannethour + "time"; if (m_bolShowMinute) document.all.tiannetMinuteHead.InnerText = TiannetMinute + "Minutes"; TianNetSetValue (false); // Attribuez des valeurs à la zone de texte, mais ne masquez pas ce contrôle} // Définissez la fonction du jour d'affichage TianNetSetDay (YY, MM) {setRealDayCount (); // Définit le jour réel du mois TiannetWriteHead (); var strdatefont1 = "", strdatefont2 = "" // entraîner le style de l'affichage de la date pour (var i = 0; i <37; i ++) {tiannetArday [i] = ""}; // efface tous les contenus de la boîte d'affichage var day1 = 1; var Premierday = nouvelle date (yy, mm-1,1) .getDay (); // jour de la semaine du premier jour d'un certain mois pour (var i = premier jour; day1 <getMonthCount (yy, mm) +1; i ++) {tiannetarrday [i] = day1; day1 ++; } // Si la valeur de la première cellule utilisée pour afficher la dernière ligne de la journée est vide, masquez toute la ligne. // if (tiannetarrday [35] == "") {// document.all.trtiannetday5.style.display = "Aucun"; //} else {// document.all.trtiannetday5.style.display = ""; //} pour (var i = 0; i <37; i ++) {var da = evale strdatefont1 = "<font color = # f0000>" strdatefont2 = "</font>"} else {strdatefont1 = ""; strdatefont2 = ""} da.innerhtml = strdatefont1 + tiannetarrday [i] + strdatefont2; // Si c'est le jour actuellement sélectionné, modifiez la couleur 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 = "default"}} // end pour tiannetsetvalue (false); // attribue une valeur ChecksElect (objSelect, selectValue) {var count = paSeInt (objSelect.length); if (selectValue <10 && selectValue.toString (). Length == 2) {selectValue = selectValue.SubString (1,2); } pour (var i = 0; i <count; i ++) {if (objselect.options [i] .value == selectValue) {objSelect.selectedIndex = i; casser; }} // pour} // sélectionnez la fonction de boîte déroulante selectObject () {// Si l'année est inférieure à l'année minimale autorisée, créez l'option correspondante if (tiannetyear <tiannetySeSt) {for (var i = tiannetyear; i <tiannetyaSeSt; i ++) {createOption (document.all.Seltianyear, i, i + "); } TianNetyeStSt = TianNetyEar; } // Si l'année dépasse l'année maximale autorisée, créez l'option correspondante if (TiannetyEar> TianNetyEarend) {for (var i = tiannetyAreend + 1; i <= tiannetyear; i ++) {createOption (document.all.seltianyear, i, i + "année"); } 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); } // Attribuez une valeur au contrôle qui accepte la date et l'heure // paramètres bolhideControl - s'il faut masquer la fonction de contrôle TianNetSetValue (bolhideControl) {var value = ""; if (! tiannetday || tiannetday == "") {tiannetOutObject.value = valeur; retour; } var mm = tiannetMonth; var day = tiannetday; if (mm <10 && mm.toString (). Longueur == 1) mm = "0" + mm; if (day <10 && day.toString (). length == 1) day = "0" + jour; Value = TianNetyEar + TiannetDatesplit + MM + TiannetDatesplit + Day; if (m_bolShowHour) {var hour = tiannethour; if (hour <10 && hour.toString (). length == 1) hour = "0" + hour; Valeur + = TiannetDateTimesplit + Hour; } if (m_bolShowMinute) {var minute = tiannetMinute; if (minute <10 && minute.toString (). length == 1) minute = "0" + minute; valeur + = TiannettimetimeSplit + minute; } tiannetoutObject.value = valeur; //Document.all.divtiannetdate.style.display = "Aucun"; if (bolhideControl) {TianNetEtHideControl (); }} // affiche-t-il la fonction de temps showtime () {if (! M_bolshowhour && m_bolshowMinute) {alert ("Si vous souhaitez sélectionner les minutes, vous devez pouvoir sélectionner des heures!"); retour; } hideelementsbyid (nouveau array ("tiannethourhead", "seltianhour", "tiannetminutehead", "seltianMinute"), true); if (m_bolShowHour) {// Afficher des heures hideelementsById (new Array ("TianneThourhead"), false); } if (m_bolShowMinUte) {// Afficher les minutes hideelementsById (nouveau array ("TianNetHourHead"), false); } if (m_bolShowMinute) {// Afficher les minutes hideelementsById (nouveau array ("TiannetMinuteHead"), false); }} // Le contrôle de sélection du calendrier apparaît pour permettre à l'utilisateur de sélectionner la fonction TiannetPopCalendar () {// Masquer la boîte déroulante pour afficher la tête HideelementsById correspondante (New Array ("Seltianyear"), true); hideelementsByid (New Array ("TianNetyEahead", "TiannetMonthhead", "tiannetMinutehead"), false); Tiannetsetday (Tiannetyear, tiannetmonth); tiannetwritehead (); afficher l'heure(); var dads = document.all.divtiannetdate.style; var ix, iy; var h = document.all.divtiannetdate.offsetheight; var w = document.all.divtiannetdate.offsetwidth; // Calculer la gauche 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; // calculer le 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; papa.left = ix; papa.top = iy; TiannetShowControl (); selectObject (); } // masquer le contrôle du calendrier (affichant les balises cachées forcées en même temps) TiannetHideControl () {document.all.divtiannetdate.style.display = "None"; TiannetShowObject (); ArtianneThide = new Array (); // effacer l'objet de balise cachée} // affiche le contrôle du calendrier (masquer les balises obscurcies en même temps) TiannetshowClaTrol () {document.all.divtiannetdate.style.display = ""; TianneThideObject ("SELECT"); TiannetHideObject ("objet"); } // Masquer les balises en fonction du nom de balise. Si la sélection du contrôle sera bloquée, la fonction d'objet TianNetHideObject (strtagname) {x = document.all.divtiannetDate.offsetLeft; y = document.all.divtiannetdate.offsetTop; h = document.all.divtiannetdate.offsetheight; w = document.all.divtiannetdate.offsetwidth; pour (var i = 0; i <document.all.tags (strtagname) .length; i ++) {var obj = document.all.tags (strtagname) [i]; if (! Obj ||! Obj.offsetparent) Continuez; // Obtenez les coordonnées relatives de l'élément pour la balise corporelle 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; } // alerte ("Extrémité gauche du contrôle:" + x + "Sélectionner l'extrémité gauche" + (objleft + objwidth) + "en bas du contrôle:" + (y + h) + "select high:" + objtop); var bolhide = true; if (obj.style.display == "Aucun" || obj.style.visibilité == "Hidden" || obj.getAttribute ("auteur") == "Tiannet") {// Si la balise elle-même est masquée, il n'a plus besoin d'être caché. S'il s'agit d'une boîte déroulante dans le contrôle, il n'a pas besoin d'être caché. bolhide = false; } if (((objleft + objwidth)> x && (y + h + 20)> objtop && (objtop + objHeight)> y && objleft <(x + w)) && bolhide) {//arrtiannethide.push(OBJ) ;//record objet caché artiannethide [arttiannethide. obj.style.visibilité = "Hidden"; }}} // Afficher la fonction de balise cachée TiannetShowObject () {for (var i = 0; i <ArrtianneThide.length; i ++) {// alert (ArtianneThide [i]); Arrtiannethide [i] .style.visibilité = ""; }} // Date d'initialisation. fonction tiannetInitDate (strdate) {var arr = strdate.split (tiannetdatesplit); tiannetyear = arr [0]; TiannetMonth = arr [1]; tiannetday = arr [2]; } // Clear Fonction tiannetClear () {tiannetoutObject.value = ""; TiannetHideControl (); } // Fermez le contrôle lorsque vous cliquez sur n'importe quel document de fonction.OnClick () {avec (window.event.srcelement) {if (tagname! = "Input" && getAttribute ("Author")! = "Tiannet") tiannetheDeControl (); }} // Appuyez sur la touche ESC pour fermer le document de la fonction de contrôle.onKeyPress () {if (event.KeyCode == 27) {TianNetHideControl (); }}Pour plus d'informations sur le contenu lié à JavaScript, veuillez consulter les sujets de ce site: "Résumé des compétences de l'opération JSON en JavaScript", "Résumé des compétences JavaScript Switching Effects and Techniques", "Résumé des effets spéciaux et techniques", «Sommage des erreurs et des techniques de débogage Javascrip Compétences d'algorithme "," Résumé des algorithmes et techniques de traverse JavaScript "et" Résumé de l'utilisation des opérations mathématiques JavaScript "
J'espère que cet article sera utile à la programmation JavaScript de tous.