Indonesia
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http ://www.w3.org/1999/xhtml"> <head> <title> JS 日历downcodes.com </title> <meta name="author" content="建站学院"> <meta name="keywords" content="js日历,calender"> <meta name="description" content="js日历"> <script type="text/javascript"> function HS_DateAdd(interval,number,date){ number = parseInt(number); if (typeof(date)=="string"){var date = new Date(date.split("-")[0],date.split("-")[1],date.split("-" )[2])} if (typeof(date)=="object"){var date = date} switch(interval){ case "y":return new Date(date.getFullYear()+number,date.getMonth( ),tanggal.getDate()); merusak; case "m":return new Date(date.getFullYear(),date.getMonth()+number,checkDate(date.getFullYear(),date.getMonth()+number,date.getDate())); merusak; case "d":kembalikan Tanggal baru(date.getFullYear(),date.getMonth(),date.getDate()+number); merusak; case "w":mengembalikan Tanggal baru(tanggal.getFullYear(),date.getMonth(),7*number+date.getDate()); merusak; } } fungsi tanggal periksa(tahun,bulan,tanggal){ var tanggal akhir = ["31","28","31","30","31","30","31","31","30 ","31","30","31"]; var tanggal kembali = ""; if (tahun%4==0){enddate[1]="29"} if (date>enddate[month]){returnDate = enddate[month]}else{returnDate = date} return returnDate; } fungsi Hari Kerja(tanggal){ var Tanggal; if (typeof(tanggal)=="string"){tanggal = Tanggal baru(tanggal.split("-")[0],tanggal.split("-")[1],tanggal.split("-") [2]);} if (typeof(date)=="object"){theDate = date} mengembalikan theDate.getDay(); } fungsi HS_calender(){ var lis = ""; var gaya = ""; /*可以把下面的css剪切出去独立一个css文件downcodes.com*/ style +="<style type='text/css'>"; style +=".calender { width:170px; height:auto; font-size:12px; margin-right:14px; background:url(calenderbg.gif) no-repeat right center #fff; border:1px solid #397EAE; bantalan:1 piksel}"; style +=".calender ul {tipe-gaya-daftar:tidak ada; margin:0; padding:0;}"; style +=".calender .day { warna latar:#EDF5FF; tinggi:20px;}"; style +=".calender .day li,.calender .date li{ float:left; width:14%; height:20px; line-height:20px; text-align:center}"; style +=".calender li a { dekorasi teks:none; font-family:Tahoma; ukuran font:11px; warna:#333}"; style +=".kalender li a:hover { warna:#f30; dekorasi teks:garis bawah}"; style +=".calender li a.hasArticle {font-weight:bold; color:#f60 !important}"; style +=".lastMonthDate, .nextMonthDate {warna:#bbb;ukuran font:11px}"; style +=".selectThisYear a, .selectThisMonth a{text-decoration:none; margin:0 2px; color:#000; font-weight:bold}"; style +=".calender .LastMonth, .calender .NextMonth{ dekorasi teks:none; color:#000; font-size:18px; font-weight:bold; line-height:16px;}"; style +=".calender .LastMonth { float:kiri;}"; style +=".kalender .Bulan Berikutnya { float:kanan;}"; style +=".calenderBody {hapus:keduanya}"; style +=".calenderTitle {text-align:center;height:20px; line-height:20px; clear:both}"; style +=".hari ini { warna latar:#ffffaa;border:1px solid #f60; padding:2px}"; style +=".hari ini a { warna:#f30; }"; style +=".calenderBottom {clear:keduanya; border-top:1px solid #ddd; padding: 3px 0; text-align:left}"; style +=".calenderBottom a {text-decoration:none; margin:2px !important; font-weight:bold; color:#000}"; style +=".calenderBottom a.closeCalender{float:kanan}"; style +=".closeCalenderBox {float:right; border:1px solid #000; latar belakang:#fff; font-size:9px; lebar:11px; tinggi:11px; tinggi garis:11px; text-align:center;overflow :tersembunyi; berat font:normal !penting}"; gaya +="</gaya>"; var sekarang; if (typeof(arguments[0])=="string"){ selectDate = argument[0].split("-"); var tahun = pilihTanggal[0]; var bulan = parseInt(selectDate[1])-1+""; var tanggal = pilihTanggal[2]; sekarang = Tanggal baru(tahun,bulan,tanggal); }else if (typeof(arguments[0])=="objek"){ sekarang = argumen[0]; } var lastMonthEndDate = HS_DateAdd("d","-1",now.getFullYear()+"-"+now.getMonth()+"-01").getDate(); var lastMonthDate = Hari Minggu(sekarang.getFullYear()+"-"+sekarang.getMonth()+"-01"); var thisMonthLastDate = HS_DateAdd("d","-1",now.getFullYear()+"-"+(parseInt(now.getMonth())+1).toString()+"-01"); var thisMonthEndDate = thisMonthLastDate.getDate(); var thisMonthEndDay = thisMonthLastDate.getDay(); var hari iniObj = Tanggal baru(); hari ini = hari iniObj.getFullYear()+"-"+hari iniObj.getMonth()+"-"+hari iniObj.getDate(); for (i=0; i<lastMonthDate; i++){ // Tanggal Bulan Lalu lis = "<li class='lastMonthDate'>"+lastMonthEndDate+"</li>" + lis; Tanggal Akhir Bulan Terakhir--; } for (i=1; i<=thisMonthEndDate; i++){ // Tanggal Bulan Ini if(hari ini == sekarang.getFullYear()+"-"+now.getMonth()+"-"+i){ var TodayString = sekarang.getFullYear()+"-"+(parseInt(now.getMonth())+1).toString()+"-"+i; lis += "<li><a href=javascript:void(0) class='hari ini' onclick='_selectThisDay(this)' title='"+now.getFullYear()+"-"+(parseInt(now. getMonth())+1)+"-"+i+"'>"+i+"</a></li>"; }else{ lis += "<li><a href=javascript:void(0) onclick='_selectThisDay(this)' title='"+now.getFullYear()+"-"+(parseInt(now.getMonth( ))+1)+"-"+i+"'>"+i+"</a></li>"; } } varj=1; for (i=thisMonthEndDay; i<6; i++){ // Tanggal Bulan Depan lis += "<li class='nextMonthDate'>"+j+"</li>"; j++; } lis += gaya; var CalenderTitle = "<a href='javascript:void(0)' class='Bulan Berikutnya' onclick=HS_calender(HS_DateAdd('m',1,'"+now.getFullYear()+"-"+now.getMonth( )+"-"+sekarang.getDate()+"'),ini) title='Bulan Depan'>»</a>"; CalenderTitle += "<a href='javascript:void(0)' class='LastMonth' onclick=HS_calender(HS_DateAdd('m',-1,'"+now.getFullYear()+"-"+now.getMonth ()+"-"+sekarang.getDate()+"'),ini) title='Bulan Sebelumnya'>«</a>"; CalenderTitle += "<span class='selectThisYear'><a href='javascript:void(0)' onclick='CalenderselectYear(this)' title='Klik di sini untuk memilih tahun lain' >"+now.getFullYear() +"</a></span>年<span class='selectThisMonth'><a href='javascript:void(0)' onclick='CalenderselectMonth(this)' title='Klik di sini untuk memilih bulan lainnya'> "+(parseInt(sekarang.getMonth())+1).toString()+"</a></span>月"; if (argumen.panjang>1){ argumen[1].parentNode.parentNode.getElementsByTagName("ul")[1].innerHTML = lis; argumen[1].parentNode.innerHTML = CalenderTitle; }else{ var CalenderBox = style+"<div class='calender'><div class='calenderTitle'>"+CalenderTitle+"</div><div class='calenderBody'><ul class='day'><li >日</li><li>一</li><li>二</li><li>三</li><li>四</li><li>五</li><li>六</li></ul><ul class='date' id='thisMonthDate'>"+lis+"</ul></div><div class='calenderBottom'><a href='javascript:void( 0)' class='closeCalender' onclick='closeCalender(this)'>×</a><span><span><a href=javascript:void(0) onclick='_selectThisDay(this)' title=' "+todayString+"'>Hari ini</a></span></span></div></div>"; kembalikan Kotak Kalender; } } fungsi _pilihHari Ini(d){ var boxObj = d.parentNode.parentNode.parentNode.parentNode.parentNode; boxObj.targetObj.value = d.judul; boxObj.parentNode.removeChild(boxObj); } fungsi closeCalender(d){ var boxObj = d.parentNode.parentNode.parentNode; boxObj.parentNode.removeChild(boxObj); } fungsi CalenderselectYear(obj){ var opt = ""; var Tahun ini = obj.innerHTML; for (i=1970; i<=2020; i++){ if (i==Tahun ini){ opt += "<option value="+i+"select>"+i+"</option>"; }else{ opt += "<option value="+i+">"+i+"</option>"; } } opt = "<select onblur='selectThisYear(this)' onchange='selectThisYear(this)' style='font-size:11px'>"+opt+"</select>"; obj.parentNode.innerHTML = pilih; } fungsi pilihTahun Ini(obj){ HS_calender(obj.value+"-"+obj.parentNode.parentNode.getElementsByTagName("span")[1].getElementsByTagName("a")[0].innerHTML+"-1",obj. simpul induk); } fungsi CalenderselectMonth(obj){ var opt = ""; var Bulan ini = obj.innerHTML; for (i=1; i<=12; i++){ if (i==Bulan ini){ opt += "<option value="+i+" dipilih>"+i+"</option>"; }else{ opt += "<option value="+i+">"+i+"</option>"; } } opt = "<select onblur='selectThisMonth(this)' onchange='selectThisMonth(this)' style='font-size:11px'>"+opt+"</select>"; obj.parentNode.innerHTML = pilih; } fungsi pilihBulan Ini(obj){ HS_calender(obj.parentNode.parentNode.getElementsByTagName("span")[0].getElementsByTagName("a")[0].innerHTML+"-"+obj.value+"-1",obj. simpul induk); } fungsi HS_setDate(inputObj){ var calenderObj = document.createElement("span"); calenderObj.innerHTML = HS_calender(Tanggal baru()); calenderObj.style.position = "mutlak"; kalenderObj.targetObj = inputObj; inputObj.parentNode.insertBefore(calenderObj,inputObj.nextSibling); } </script> <style> body {ukuran font:12px} td {text-align:center} h1 {ukuran font:26px;} h4 {ukuran font:16px;} em {warna:#999; margin:0 10 piksel; ukuran font:11px; display:block} </style> </head> <body> <h1>Pemilih Tanggal</h1> <h4 style="border-bottom:1px solid #ccc">ver:1.0</h4> <tabel border= 1 lebar=400 tinggi=150> <tr> <td>文本文本文本</td> <td>点击输入框</td> <td>文本文本文本</td> </tr> <tr> <td >点击输入框</td> <td><input type="text" style="width:70px" onfocus="HS_setDate(this)">文本</td> <td>文本文本文本</td> < /tr> <tr> <td>文本文本文本</td> <td>点击输入框</td> <td>文本<input type="text" style="width:70px" onfocus="HS_setDate(ini )">文本</td> </tr> </table> <ul> <li>不需要其他框架类库</li> <li>支持ie6、firefox、opera</li> <li>点击年份与月份可以下拉选择</li> </ul> </body> </html>