十几行的超简日历组件【麻雀虽小,五脏俱全(兼容FF),等待史上最小的日历】
|
admin
2011年4月12日 1:7
本文热度 4546
|
十几行的超简日历组件【麻雀虽小,五脏俱全(兼容FF),等待史上最小的日历】
[code]
<script>
(CLD={init:function (){this.$=new Date;this.update()},update:function(y,m){
var uiList=[],week='日一二三四五六'.split(''),$=this.$,Y=$.getFullYear(),M=$.getMonth(),D=$.getDate(),
fn=function(a,b){return '
'+b+''};
y&&$.setYear(Y+y),m&&$.setMonth(M+m),Y=$.getFullYear(),M=$.getMonth();
var fDay=new Date(Y,M,1).getDay(),dCount=new Date(Y,M+1,0).getDate();
for (var i=0;i
'+week[i]+'');
for (i=0;i ');
for (i=0;i'+(i+1)+'');
iCalendar.innerHTML=fn('-1,null','<<')+fn('null,-1','<')+''+$.getFullYear()+'年'+($.getMonth()+1)+'月'+ fn('null,1','>')+fn('1,null','>>')+uiList.join('');
}
}).init()
</script>
[/code]
该文章在 2011/4/12 1:07:40 编辑过