[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
It is too urgent to consider compatibility.
It is implemented through two classes: Panel class and calendar class.
Since all public js files are loaded at one time in the top-level window during development, you must upload the current window object when creating the object in the subwindow, for example, var panel = new parent. parent. selectPanel (self); If the self parameter is not passed, the js window is loaded by default.
The Gregorian algorithm marcian found on the Internet is a bit complicated. I obtain the maximum number of days in the current month, and the number of days in the week on the first day of the current month is directly implemented through the Date function provided by JS.
Copy codeThe Code is as follows:
// Obtain the maximum number of days in a month
// Asfman provides a simpler method: return (new Date (y, m + 1, 0). getDate ()
Function GetDates (year, month)
{
Var date = new Date (year, month, 31 );
Return 31-date. getDate () | 31;
}
// Obtain the day of the week on the first day of the month.
Function GetFirstDay (year, month)
{
Return (new Date (year, month, 1). getDay ();
}
/* The following part can be ignored, because even if new Date (2007,-1, 31) occurs, the Date will be automatically converted to Date (2006, 12, 31)
If (month <0)
{
Month = 11;
Year --;
}
If (month = 12)
{
Month = 0;
Year ++;
}*/