Cet article décrit la mise en œuvre d'un sélecteur de date qui est exact aux secondes par JS. Partagez-le pour votre référence, comme suit:
<Script> // La fonction d'appel principal est détresse (this, [objet]) et setday (this). [Objet] est le nom de contrôle Sortie par le contrôle. Donnez deux exemples: // 1. <Input name = txt> <input type = Button Value = setday onclick = "setday (this, document.all.txt)"> // 2. <Entrée onfocus = "Setday (this)"> var bmoveable = true; var strframe; Z-index: 9998; 1px solide; fond-couleur: # 63A3E9; font-famille: 安安;} '; strFrame + =' td {font-size: 9pt; font-family: 安安安;} '; strframe + =' </ style> '; strframe + =' <scr '+' ipt> '; strframe + =' var dateladerx, dataLayy;;;; bdrag; '; strFrame + =' function document.onmousmove () '; strFrame + =' {if (bdrag && window.event.button == 1) '; strFrame + =' {var dateLyer = Parent.Document.all.endDateLyer. window.event.clientx-dateLayerx; '; strFrame + =' dateLayer.postop + = window.event.clienty-dateLayery;}} '; strFrame + =' function dragstart () '; strframe + =' {var dateLyer dateLayerx = window.event.clientx; '; strFrame + =' dateLayery = window.event.clienty; '; strFrame + =' bdrag = true;} '; strFrame + =' function dragend () {'; strframe + =' bdrag = false;} '; strFrame + =' </ scr '+' ipt> style = "z-index: 9999; position: absolu; gauche: 0; top: 0;" onSelectStart = "return false"> '; strFrame + =' <span id = tmpelectyearlayer style = "z-index: 9999; position: absolu; top: 3; gauche: 19; affichage: non"> </span> '; strframe + =' <span id = tmpselectmonthlayyer style = "z-index: 9999; position: Absolute: Absolut; Aucun "> </ span> '; strFrame + =' <span id = tmpselecthourlayer style =" z-index: 9999; position: absolu; top: 188; 77px; Affichage: Aucun "> </span> '; strFrame + =' <span id = tmpSelectSecondLayer 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> '; strframe + =' <tr allign = '; <td width = 16 align = Center bgColor = # 63a3e9 style = "font-size: 12px; cursor: hand; couleur: #ffffff" '; strFrame + =' onclick = "Parent.meizzprevm ()"> <b> << / b> </td> '; strframe + =' <td width = 60 ALLING = "Centre" bgcolor = "# 63a3e9" style = "font-size: 12px; cursor: hand" '; strframe + =' onMouseover = "style.backgroundcolor = / '# aaccf3 /' ''; strframe + = 'onMouseout =" style.backgroundcolor = /' # 63a3e9 / '' ''; Strframe + = ' onClick = "Parent.tmpSelectyeArinnerHtml (this.innerText.Substring (0,4))" '; strFrame + ='> <span id = meizzyearhead> </span> </pd> '; strFrame + =' <td width = 48 align = "Center" Style = "Font-Size: 12px; font-color: #ffff; Cursor: Handsor: Handsor: Hands '; strFrame + =' bgColor = "# 63A3E9" onMouseOver = "style.backgroundColor = / '# aaccf3 /'" '; strFrame + =' onMouseout = "style.backgroundcolor = / '# 63a3e9 /' ''; strFrame + = ' onClick = "Parent.tmpSelectMonthinnerHtml (this.innerText.length == 3? this.innerText.substring (0,1): this.innertex 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 Cellpacing = 0 CellPadding = 2 bgcolor = # 63a3e9 '+ (bmoveable?' onMouseDown = "dragstart ()" onMouseUp = "Dragend ()": "strframe + =" onMouseUp = "Dragend ()": "strframe + =" onMouseUp = "Dragend ()": "strframe + =" onMouseUp = "Dragend ()". BorderColorlight = # 63A3E9 BorderColordark = # fffffff width = 140 height = 20 style = "Cursor: '+ (bmoveable?' Move ':' Default ') +'"> '; strFrame + =' <Tr> <td style = "Font-Size: 12px; Color: #ffff" width = 20> day </ td> ';; style = "Font-Size: 12px; couleur: #ffffff"> un </td> <td style = "font-size: 12px; couleur: #ffffff"> t </td> '; strFrame + =' <td style = "font-size: 12px; couleur: #ffffff"> un </td> <td; style = "font-size: 12px; couleur: #ffffff"> t </td> '; strFrame + =' <td style = "font-size: 12px; couleur: #ffffff"> un </td> <td style = "Font-size: 12px; coloride: #ffffff"> un </td> '; strFrame + =' <Td> Style = "Font-Size: 12px; couleur: #ffffff"> six </td> <td style = "font-size: 12px; couleur: #ffffff"> six </td> <td style = "Font-Size: 12px; Color: #FFFFFF"> six </td> </tr> '; strframe + =' <tr> <td witrth = 142 height = 120; > '; strFrame + =' <Tr> <Table Border = 1 CellPacing = 2 CellPadding = 2 BorderColorlight = # 63A3E9 BorderColordark = # fffff bgColor = # fff8ec width = 140 height = 120> '; var n = 0; pour (j = 0; j <5; j ++) {strFrame + = '<tr align = Center>'; pour (i = 0; i <7; i ++) {strFrame + = '<td width = 20 height = 20 id = meizzday' + n + 'style = "font-size: 12px" onclick = parent.meizzdayClick (this.innertex (i = 35; i <37; i ++) strFrame + = '<td width = 20 height = 20 id = meizzday' + i + 'style = "font-size: 12px" onclick = "parent.meizzdayClick (this.innertex onClick = "Parent.SetNull ()" style = "font-size: 12px; cursor: hand" '; strFrame + =' onMouseOver = "style.color = / '# ff0000 /'" onMouseout = "style.color = / '# 1478eb /'"> vide </pank style = "Font-Size: 12px; Cursor: Hand" '; strFrame + =' onMouseOver = "style.color = / '# ff0000 /'" OnMouseout = "style.color = / '# 1478eb /'"> Current </ span> <span style = "Cursor: Hand" id = evaallok OnMouseOver = "Style.Color = 'Ff00000000000000000000 onMouseout = "style.color = / '# 1478eb /'" onclick = "Parent.closeLeryer ()"> Close </span> </td> </tr> '; strFrame + =' </ Table> </pd> </tr> <tr> <Td> '; Strframe + =' <Table Border = 0 Celpacing = 1 Cellpadding = 0 width = ' bgcolor = # ffffff height = 22> '; strFrame + =' <tr bgcolor = "# 63a3e9"> <td id = busEtimeLeryer width = 30 style = "Cursor: hand" '; strFrame + =' onMouseOver = "style.backgroundcolor = / '# aaccf3 /'" align = Centre = Centre = onMouseout = "style.backgroundColor = / '# 63a3e9 /'" '; strFrame + =' onClick = "Parent.UseTime (this)"> '; strFrame + =' <span> </span> </td> '; strFrame + =' <td style = "cursor: hand" onClick = "Parent.tmpSelectHourinnerHtml (this.innerText.length == 3? this.innerText.substring (0,1): this.innertext.substring (0,2))" '; strFrame + =' onMouseOver = "style.backgroundColor = / '# aaccf3 /'" onMouseout = "style.backgroundColor = / '# 63A3E9 /'" '; strFrame + =' align = Center Width = 42> '; strFrame + =' <span id = meizzhourhead> </span> </td> '; strFrame + =' <td style = "cursor: main" onclick = "Parent.tmpSelectMinuteInnerHtml (this.innerText.length == 3? this.innerText.substring (0,1): this.innerText.Substring (0,2))" '; strFrame + =' onMouseOver = "style.backgroundcolor = / '# aaccf3 /'" " onMouseout = "style.backgroundColor = / '# 63A3E9 /'" '; strFrame + =' align = Center Width = 42> '; strFrame + =' <span id = meizzMinutehead> </ span> </pd> '; strframe + =' <td style = "cursor: hand" onClick = "Parent.tmpSelectSeConDinnerHtml (this.innerText.length == 3? this.innerText.substring (0,1): this.innerText.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 (); // résoudre le problème que la barre de progression IE ne fait pas end//================================================================================================================= =====================================================================. =====================================================================. Affichage de la page Web partie ================================================================================================================================================== ==========================================================================. ==========================================================================. ==========================================================================. ==========================================================================. ==========================================================================. ==========================================================================. ==========================================================================. odateLayer = window.enddateLayer.Document.all; // odateLayer.busetimeLeryer.innerText = "no"; bimgSwitch (); function odateLayer.busetimeLer.Innerhtml = bimg; Paramètres transmis dans ce contrôle! "); return;} if (arguments.length == 0) {alert (" Désolé! Vous n'avez transmis aucun paramètre à ce contrôle! "); return;} var dads = document.all.enddateLeryer.style; var th = tt; var ttop = tt.offsetop; // Le point de positionnement du contrôle TT est élevé var ils = tt.ClientHeight; // Le var élevé du contrôle TT lui-même est tleft = tt.offsetLeft; // Le point de positionnement du contrôle TT est large var ttyp = tt.type; // Le type du contrôle TT est while (tt = tt.offsetparent) {ttop + = tt.offSetTop; tleft + = tt.offsetleft;} dads.top = (ttyp == "image")? ttop + thei: ttop + thei + 6; dads.left = tleft; OutObject = (arguments.length == 1)? Th: Obj; Outbutton = (arguments.length == 1)? NULL: TH; // Définissez le bouton cliqué externe // Afficher l'année civile et le mois var reg = / ^ (/ d +) - (/ d {1,2}) - (/ d {1,2}) /; // excluant le temps var r = outObject.value.match (reg); if (r! = Null) {r [2] = r [2] -1; var d = nouvelle date (r [1], r [2], r [3]); if (d.getlyear () == 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 {Outdate = ""; } meizzsetDay (r [1], r [2] +1);} else {Outdate = ""; MeizzSetDay (new Date (). Gettillyear (), new Date (). GetMonth () + 1);} dads.display = ''; // jugez si le temps d'utilisation est utilisé pendant l'initialisation, Verification non stricte // if (outobject.value.length> 10) // {bodetime = true; bimgSwitch (); odateLayer.buseTimeLayer.innerHtml = bimg; meizzwritehead (meizztheyear, meizzthemonth); //} // else // {// busetime = false; // bimgSwitch (); // odateLer (e) {// L'erreur est exclue ici, la cause de l'erreur n'a pas encore été trouvée. }} var monhead = nouveau tableau (12); // Définissez le nombre maximum de jours par mois dans le calendrier grégorien Monhead [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 (). Gettillyear (); // Définissez la valeur initiale de la variable de l'année var meizzthemETH = new Date (). GetMonth () + 1; // Définissez la valeur initiale de la variable du mois var meizzTheDate = new Date (). GetDate (); // Définissez la valeur initiale de la variable du jour var meizzthehour = new Date (). Gethours (); // Définissez la valeur initiale de la variable heure var meizzTheMinute = new Date (). GetMinutes (); // Définissez la valeur initiale de la variable minute var meizzTheSEcond = new Date (). GetSeconds (); // Définissez la valeur initiale de la deuxième variable var meizzwday = nouveau tableau (37); // Array qui définit le document de date d'écriture.OnClick = (function () {avec (window.event) {if (srcelement! = OutObject && srcelement! = Outbutton) CloseLayer ();}}) document.onkeyup = (function () {if (window.event.Keycode == 27) {if (OutObject) outObject.Blur (); CloseLyer ();} else if (document.activeElement) {if (document.activeElement! = OutObject && document.activeElement! = Outbutton) {CloseLayer (); "Year"; odateLayer.meizzMonthhead.InnerText = format (mm) + "Moon"; // insérer l'heure et la minute en cours odateLery.meizzhourhead.innertex Minutes "):" "; odateLayer.meizzSecondhead.InnerText = BuseTime? (MeizzTheSecond +" Seconds "):" ";} Fonction tmpelectyeAnnerHtml (Stryear) // Drop-down Box pour l'année {if (Stryear.match (// d /)! = Null) {Alert (" Le paramètre d'entrée de l'année n'est pas a Numéro! "); retour;} var m = (stryear)? STRYEAR: NOUVEAU DATE (). GETLILYEARD (); if (m <1000 || m> 9999) {alert ("La valeur de l'année n'est pas entre 1000 et 9999!"); RETOUR;} var n = m - 50; if (n <1000) n = 1000; if (n + 101> 9999) n = 9974; var s = "<SELECT NAME = TMPSELTYE = ' 12px '"s + =" onblur =' document.all.tmpselectyearlayer.style.display = / "Aubone /" '"s + =" onchange =' document.all.tmpselectyearlayer.style.display = / "Aucun /"; "s + =" parent.meizztheear = this.value; Parent.meizzsetday (parent.meizztheear, parent.meizzthemonth) '> / r / n "; var selectInnerHtml = s; for (var i = n; i <n + 101; i ++) {if (i == m) {selectInnerhtml + =" <option value =' "+ i +" 'sélectionné> "+ i +" an "+" annue "+"; } else {selectInnerhtml + = "<option value = '" + i + "'>" + i + "année" + "</ option> / r / n"; }} selectInnerhtml + = "</lect>"; odateLayer.tmpSelectyearLayer.style.display = ""; odateLayer.tmpselectyearlayer.innerhtml = selectinnerhtml; odateLayer.tmpselectyear.focus ();} fonction tmpelectmonthinnerhtml (strmmonth) // box put-down pour le mois {if (strmonth.match (// d /)! = null) {alert ("Le paramètre d'entrée du mois n'est pas un nombre!"); return;} var m = (stronth)? stronth: new Date (). getMonth () + 1; var s = "<select name = tmpSelectMonth style = 'font-size: 12px'" s + = "onblur = 'document.all.tmpselectmonthlayer.style.display = /" nul / "'" s + = "onchange = 'document.all.tmpselectmonthlayer.style.display = /" non / ";" s + = "parent.meizzthemonth = this.value; parent.meizzsetday (parent.meizzTheyear, parent.meizzthemonth)'> / r / n"; var helpinnerhtml = s; pour (var i = 1; (i == m) {selectInnerhtml + = "<option value = '" + i + "' selected>" + i + "mois" + "</ option> / r / n"; } else {selectInnerhtml + = "<option value = '" + i + "'>" + i + "mois" + "</ option> / r / n"; }} selectInnerhtml + = "</lect>"; odateLayer.tmpSelectMonthLayer.style.display = ""; odateLayer.tmpSelectMonthlayer.innerhtml = selectinnerhtml; odateLayer.tmpselectmonth.focus ();} / ***** ajoute des heures *** / fonction * tmpSelectThourinnerHtml (strhour) // hour drop-down box {if (! busEtime) {return;} if (strhour.match (// d /)! = null) {alert ("hour les paramètres d'entrée ne sont pas des nombres!"); return;} var m = (strhour)? strhour: new Date (). gethours (); var s = "<select name = tmpselecthour style = 'font-size: 12px'" s + = "onblur = 'document.all.tmpselecthourlayer.style.display = /" nul / "'" s + = "onchange = 'document.all.tmpselecthourlayer.style.display = /" non / ";" s + = "parent.meizzthehour = this.value; parent.evasettime (parent.meizztheHour, parent.meizzthemite);'> / r / n"; var selectInnerhtml = s; pour (var i = 0; (i == m) {selectInnerhtml + = "<option value = '" + i + "' selected>" + i + "</ option> / r / n"; } else {selectInnerhtml + = "<option value = '" + i + "'>" + i + "</ option> / r / n"; }} selectInnerhtml + = "</lect>"; odateLayer.tmpselecthourLayer.style.display = ""; odateLayer.tmpselecthourlayer.innerhtml. tmpSelectMinuteInnerHtml (strMinute) // Minute Drop-Down Box {if (! busEtime) {return;} if (strminute.match (// d /)! = null) {alert ("Paramètre d'entrée minute n'est pas un nombre!"); retour;} var m = (strminuute)? strMinute: new Date (). getMinutes (); var s = "<select name = tmpSelectMinute style = 'font-size: 12px'" s + = "onblur = 'document.all.tmpselectMinuteLer.style.display = /" non "onchange = 'document.all.tmpselectMinuteLayer.style.display = /" None / ";" S + = "Parent.meizzTheMinute = this.value; parent.evasettime (parent.meizzthehour, parent.meizzthemite);'> / r / n"; i ++) {if (i == m) {selectInnerhtml + = "<option value = '" + i + "' selected>" + i + "</ option> / r / n"; } else {selectInnerhtml + = "<option value = '" + i + "'>" + i + "</ option> / r / n"; }} selectInnerhtml + = "</lect>"; odateLayer.tmpselectMinuteLayer.style.display = ""; odateLayer.tmpselectMinuteLer.innerhtml = selectInnerHtml; odateLayer.tmpselectMinute.focus ();} fonction tmpSelectSecondInnerHtml (strsecond) // deuxième boîte déroulante {if (! busEtime) {return;} if (strsecond.match (// d /)! = null) {alert ("Paramètre d'entrée minute n'est pas un nombre!"); return;} var m = (strececond)? strseCond: new Date (). getMinutes (); var s = "<select name = tmpSelectSecond style = 'font-size: 12px'" s + = "onblur = 'document.all.tmpselectsecondlayer.style.display = /" non / "'" s + = "onchange = 'document.all.tmpselectsecondlayer.style.display = /" non / ";" s + = "parent.meizzthesecond = this.value; parent.evasettime (parent.meizzthehour, parent.meizztheminute, parent.meizzthesecond);'> / r / n"; 0; } else {selectInnerhtml + = "<option value = '" + i + "'>" + i + "</ option> / r / n"; }}selectInnerHTML += "</select>";odatelayer.tmpSelectSecondLayer.style.display="";odatelayer.tmpSelectSecondLayer.innerHTML = selectInnerHTML;odatelayer.tmpSelectSecond.focus();}function closeLayer() // Close of this layer {var o = document.getElementById ("endDateLayer"); if (o! = null) {o.style.display = "non";}} fonction showlayer () // la fermeture de cette couche {document.all.enddateLyer.style.display = "} function ispinyear (an) // (0 == Année% 4 && ((année% 100! = 0) || (année% 400 == 0))) Retour True; else return false;} function getMonthCount (année, mois) // février de Leap Year est 29 jours {var c = monhead [mois-1]; if ((mois == 2) && iSpinyear (année)) C ++; Retour C La semaine d'un certain jour {var c = monhead [Month-1]; if ((mois == 2) && ispinyear (année)) c ++; retour c;} fonction getDow (jour, mois, année) // trouver le jour de la semaine d'un certain jour {var dt = nouvelle date (année, mois 1, jour) .getDay () / 7; return dt;} function meizzprevy () // flip année {if (meizztheyear> 999 && meizztheyear <10000) {meizztheyear -;} else {alert ("année hors de portée (1000-9999)!");} meizzsedday (meizztheear, meizzthemonth);} function meizznexy () //plipthear Année {if (meizztheyear> 999 && meizztheyear <10000) {meizztheyear ++;} else {alert ("année hors de portée (1000-9999)!");} Meizzsetday (meizztheyear, meizzthemone);} function setnull () {ooutobject.value = '; meizztoday () // bouton d'aujourd'hui {parent.meizzTheyEar = new Date (). Gettillyear (); parent.meizzthemonth = new Date (). getMonth () + 1; parent.meizzThedate = new Date (). GetDate (); Parent.meizzTheHour = new Date (). Gethours (); Parent. Date (). GetMinutes (); parent.meizzTheSEcond = new Date (). GetSeconds (); var meizzTheseConde = new Date (). GetSeconds (); if (meizzthemonth <10 && meizzthemonth.length <2) // Format It en deux digits {SAPENIR (Parent.meizzThedate <10 && parent.meizzThedate.length <2) // Format en deux chiffres {parent.meizzthedate = "0" + parent.meizzthedate;} // meizzsetday (meizztheyear, meizzthemone); if (OutObject) {if (bodetime) {OutoBject.Value = Parent format (parent.meizzthemonth) + "-" + format (parent.meizzThedate) + "" + format (parent.meizzthehour) + ":" + format (parent.meizztheminute) + ":" + format (parent.meizzthesecond); // Remarque: Ici, vous pouvez modifier la sortie au format que vous souhaitez} else {OutObject.Value = Parent.meizzTheyEar + "-" + Format (Parent.meizzThemonth) + "-" + format (parent.meizzThedate); // Remarque: Ici, vous pouvez modifier la sortie au format que vous souhaitez}} CloseLayer ();} fonction meizzprevm () // suivez le mois en avant {if (meizzthemonth> 1) {meizzthemonth -} else {meizztheear -; meizzthemonth = 12;} meizzseday (meizztheear, meizzthet Mois en arrière {if (meizzthemonth == 12) {meizztheyear ++; meizzthemonth = 1} else {meizzthemonth ++} meizzsetday (meizztheyear, meizzthemonth);} // todo: organiser la fonction de code meizzsetday (yy, mm) // le programme d'écriture principal du programme d'écriture *********. // efface tous les contenus de la boîte d'affichage var day1 = 1, day2 = 1, premier jour = nouvelle date (yy, mm-1,1) .getDay (); // Quel jour de la semaine du premier jour d'un certain mois pour (i = 0; i <premier jour; i ++) meizzwday [i] = getMonthCount (mm == 1? Yy-1: yy, mm == 1? 12: mm-1)-premier jour + i + 1 // les derniers jours de la dernière mois pour (i = premier jour; meizzwday [i] = day1; day1 ++; } pour (i = premier jour + getMonthCount (yy, mm); i <37; i ++) {meizzwday [i] = day2; day2 ++; } pour (i = 0; i <37; i ++) {var da = eval ("odateLayer.meizzday" + i) // avec l'arrangement de date et de semaine du nouveau mois if (meizzwday [i]! = "") {// initialiser la bordure da.bordercolorlight = "# 63a3e9"; da.borderColordark = "# 63A3E9"; da.style.color = "# 1478eb"; if (i <premier jour) // la partie du mois dernier {da.innerhtml = "<b> <font color = # bcbabc>" + meizzwday [i] + "</font> </b>"; da.title = (mm == 1? 12: mm-1) + "mois" + meizzwday [i] + "jour"; da.onclick = fonction ("meizzdayClick (this.innertext, -1)"); if (! Outdate) da.style.backgroundColor = ((mm == 1? Yy-1: yy) == new Date (). Gettillyear () && (mm == 1? 12: mm-1) == new Date (). getMonth () + 1 && meizzwday [i] == new Date (). GetDate ())? "# 5CEFA0": "# f5f5f5"; else {da.style.backgroundColor = ((mm == 1? Yy-1: yy) == outdate.getlyar () && (mm == 1? 12: mm-1) == outdate.getMonth () + 1 && meizzwday [i] == outdate.getDate ())? "# 84c1ff": ((mm == 1? Yy-1: yy) == new Date (). Gettillyear () && (mm == 1? 12: mm-1) == new Date (). GetMonth () + 1 && meizzwday [i] == new Date (). GetDate ())? "# 5CEFA0": "# f5f5"); // montre la date sélectionnée comme concave if ((mm == 1? Yy-1: yy) == outdate.getlyar () && (mm == 1? 12: mm-1) == outdate.getMonth () + 1 && meizzwday [i] == Outdate.getDate ()) {da.borderColorlight = "# fffff"; da.borderColordark = "# 63A3E9"; }}} else if (i> = premier jour + getMonthCount (yy, mm)) // la partie du mois prochain {da.innerhtml = "<b> <font color = # bcbabc>" + meizzwday [i] + "</font> </b>"; da.title = (mm == 12? 1: mm + 1) + "mois" + meizzwday [i] + "jour"; da.onclick = function ("meizzdayClick (this.innertext, 1)"); if (! Outdate) da.style.backgroundColor = ((mm == 12? Yy + 1: yy) == new Date (). Gettillyear () && (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.getlyar () && (mm == 12? 1: mm + 1) == Outdate.getMonth () + 1 && meizzwday [i] == Outdate.getDate ())? "# 84c1ff": ((mm == 12? Yy + 1: yy) == new Date (). Gettillyear () && (mm == 12? 1: mm + 1) == new Date (). GetMonth () + 1 && meizzwday [i] // montre la date sélectionnée comme concave if ((mm == 12? Yy + 1: yy) == Outdate.getlyar () && (mm == 12? 1: mm + 1) == Outdate.getMonth () + 1 && meizzwday [i] == Outdate.getDate ()) {da.borderColorlight = "# fffff"; da.borderColordark = "# 63A3E9"; }}} else // partie de ce mois {da.innerhtml = "<b>" + meizzwday [i] + "</b>"; da.title = mm + "mois" + meizzwday [i] + "jour"; da.onclick = function ("meizzdayClick (this.innertext, 0)"); // donne à TD le traitement de l'événement OnClick // S'il s'agit de la date actuellement sélectionnée, un fond bleu vif s'affiche; S'il s'agit de la date actuelle, un fond jaune foncé s'affiche si (! Outdate) da.style.backgroundColor = (yy == new Date (). Gettillyear () && mm == new Date (). GetMonth () + 1 && meizzwday [i] == new Date (). GetDate ())? "# 5CEFA0": "# f5f5f5"; else {da.style.backgroundcolor = (yy == outdate.getlyar () && mm == outdate.getMonth () + 1 && meizzwday [i] == Outdate.getDate ())? "# 84c1ff": ((yy == new Date (). Gettillyear () && mm == new Date (). GetMonth () + 1 && meizzwday [i] == new Date (). GetDate ())? "# 5CEFA0": "# f5f5f5"); // affiche la date sélectionnée comme concave if (yy == outdate.getlyar () && mm == outdate.getMonth () + 1 && meizzwday [i] == Outdate.getDate ()) {da.borderColorlight = "# ffffff"; da.borderColordark = "# 63A3E9"; }}} da.style.cursor = "hand"} else {da.innerhtml = ""; da.style.backgroundcolor = ""; da.style.cursor = "default"; }}} fonction meizzdayclick (n, ex) // cliquez sur la zone d'affichage pour sélectionner la date, la fonction d'entrée principale ************************ {Parent.meizzThedate = n; var yy = meizzthear; var mm = parseint (meizzthemonth) + ex; // ex représente le décalage, utilisé pour sélectionner la date du mois précédent et le mois suivant var hh = meizzthehour; var mi = meizzTheMinute; var se = meizzthesecond; // juge le mois et effectuer le traitement correspondant if (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;} // temps if (mi <10) {mi = "0" + mi;} // minutes si (se <10) {se = "0" + se;} // seconde if (outObject) {if (s = "0" + se;} // second //outObject.value= ""; return;} if (n <10) {n = "0" + n;} writeateto (yy, mm, n, hh, mi, se); CloseLayer (); if (BuseTime) {try {Outbutton.click (); } catch (e) {setday (OutObject); }}} else {roseLayer (); alert ("L'objet de contrôle que vous souhaitez sortir n'existe pas!");}} Fonction Format (n) // Formater le nombre en tant que caractères à deux chiffres pour représenter {var m = new String (); var tmp = new String (n); if (n <10 && tmp.length <2) {m = "0" + n;} else {m = n;} return m;} function evasetIon () / //set the where et the Setho Procès-verbaux sélectionnés par l'utilisateur {odateLeryer.meizzhourhead.innerText = meizzthehour + "time"; odateLayer.meizzMinutehead.innerText = meizztheMinute + "Minute; odateLyer.meizzSsecondhead.inneText = meizzTheSECOND +" secondes "; writeateto (meizztheear, meizzthemonth, meizzthedate, meizzthehour, meizztheminute, meizzthesecond)} function evasettimenothing () // définit le contrôle du temps pour vide {odatelayer.meizzhourhead.innertext = ""; odateLayer.meizzMinuteHead.InnerText = ""; odateLayer.meizzsecondhead.innertext = ""; wrezizateto (meizztheyear, meizzthemonth, meizzthedate, meizzhehour, meizzthemenet, meizzthesesect)} qui meizzhehour, meizzthemenet, meizzthesesect). evasettimeNow () // définit le contrôle du temps sur l'heure actuelle {odateLayer.meizzhourhead.innerText = new Date (). Gethours () + "time"; odateLayer.meizzMinutehead.innerText = new Date (). GetMinutes () + "Minutes"; OdateLer secondes "; meizzthehour = new Date (). gethours (); meizztheminute = new Date (). getMinutes (); meizzTheseCond = new Date (). getSeconds (); wredateto (meizztheyear, meizzthemonth, meizzthedate, meizzthehour, meizztheminuse, meizzthemonthée)} Fonction USETIME (CTL) {BUSETIME =! evasettimeNothing ();}} fonction wretedateto (yy, mm, n, hh, mi, se) {if (busEtime) {outObject.value = yy + "-" + format (mm) + "-" + format (n) + "" + format (hh) + ":" + format (mi) + ":" + format (se); La sortie du format que vous souhaitez} else {OutObject.Value = Yy + "-" + Format (mm) + "-" + format (n); onfocus = "setday (this)" id = "starttime" name = "starttime">Pour plus d'informations sur JavaScript, veuillez consulter les sujets spéciaux de ce site: "Résumé des compétences de l'opération de temps et de date JavaScript", "Résumé des compétences en algorithme de commutation JavaScript", "Résumé des effets spéciaux et compétences de la recherche JavaScript", "Résumé des compétences en JavaScript d'animation et des effets spéciaux", "Résumé des erreurs JavaScript et des compétences de déborgage", "Résumé des JavaScript Structures et algorths", "," Résumé des Javascript Structures et algorthates "," Capyscript ", Simation of Javascript Structions et AlgorHe "Résumé de l'algorithme de traverse JavaScript et des compétences" et "Résumé de l'utilisation de l'opération mathématique JavaScript"
J'espère que cet article sera utile à la programmation JavaScript de tous.