본문 바로가기

Javascript

(Javascript) 10줄 자바스크립트 달력 예제

336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

출처 : http://www.phpschool.com/gnuboard4/bbs/board.php?bo_table=tipntech&wr_id=48169


자세한 설명은 위의 출처에서 보시길..


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<html
<head
<script language="JavaScript"
function showCalendar(y, m) { 
    var text = '<table>\n<tr><td colspan=7 style="text-align:center">'
    text += '<span onclick="showCalendar('+(y-1)+','+m+')"> Y- </span>'
    text += '<span onclick="showCalendar('+(m==1?(y-1)+','+12:y+','+(m-1))+')"> M- </span>'
    text += '[' + y + '/' + ((m < 10) ? ('0' + m) : m) + ']'
    text += '<span onclick="showCalendar('+(m==12?(y+1)+','+1:y+','+(m+1))+')"> M+ </span>'
    text += '<span onclick="showCalendar('+(y+1)+','+m+')"> Y+ </span>'
    text += '</td>'
 
    var d1 = (y+(y-y%4)/4-(y-y%100)/100+(y-y%400)/400 
          +m*2+(m*5-m*5%9)/9-(m<3?y%4||y%100==0&&y%400?2:3:4))%7
    for (i = 0; i < 42; i++) { 
        if (i%7==0) text += '</tr>\n<tr>'
        if (i < d1 || i >= d1+(m*9-m*9%8)/8%2+(m==2?y%4||y%100==0&&y%400?28:29:30)) 
            text += '<td> </td>'
        else 
            text += '<td' + (i%7 ? '' : ' style="color:red;"'+ '>' + (i+1-d1) + '</td>'
    } 
    document.getElementById('calendarDiv').innerHTML = text + '</tr>\n</table>'
</script
</head
<body onload="showCalendar(2006,8)"
<div id="calendarDiv" style="font-family:Gulim;font-size:9pt;"></div
</body
</html
cs