Recommended JavaScript Calendar controls compatible with IE, FireFox
Original author: Cold Feather Maple (cityhunter172)
I. INTRODUCTION AND statement
This calendar control is the work of CSDN Netizen Kimsoft: http://blog.csdn.net/kimsoft/archive/2006/05/24/753225.aspx. The interface is refreshing, the pure script runs, realizes the date the Echo function, the most important is the compatibility FireFox.
To accommodate more requirements, I made the following modifications to the control:
1, the return date of the output format, I changed to the user as a parameter to specify style
2, on IE <select> dropdown box processing, not call hidden, but with <iframe> direct coverage
3, do not use//this.panel.style.visibility = "hidden"; Because it in FireFox will cover up before the local link text, but instead this.panel.style.display = "none";
4, the new loss of focus, the entire webcalendar is hidden
This control copyright belongs to Kimsoft, everyone in the process of use do not delete the copyright notice in the article, thank you. Thanks again for Kimsoft's open source.
Second, the revised Code
The following is the Webcalendar.js modified source code
<!--
var cal;
var isfocus = false; Whether the focus
Above for the cold feather maple 2006-06-25 added variable
Select date → 2006-06-25 added by the cold feather maple
function Selectdate (Obj,strformat)
... {
var date = new Date ();
var by = Date.getfullyear ()-50; Minimum value →50 years ago
var ey = date.getfullyear () +50; Maximum value → 50 years later
Cal = New Calendar (by, EY, 1,strformat); Initializing the English version of
Cal.show (obj);
}
/**/ /**
* Return Date
* @param d The delimiter
* @param p The pattern of your date
2006-06-25 by the cold feather maple modified to according to the user specified style to determine;
*/
String.prototype.toDate = function (x, p) {
String.prototype.toDate = function (style) ... {
/**//*
if (x = = null) x = "-";
if (p = = null) p = "Ymd";
var a = This.split (x);
var y = parseint (A[p.indexof ("Y")]);
Remember to change this next century;)
if (y.tostring (). length <= 2) y = 2000;
if (isNaN (y)) y = new Date (). getFullYear ();
var m = parseint (A[p.indexof ("M")])-1;
var d = parseint (A[p.indexof ("D")]);
if (isNaN (d)) d = 1;
return new Date (Y, M, d);
*/
var y = this.substring (style.indexof (' y '), style.lastindexof (' y ') +1);
var m = this.substring (Style.indexof (' m '), Style.lastindexof (' m ') +1);/month
var d = this.substring (Style.indexof (' d '), Style.lastindexof (' d ') +1);//day
if (isNaN (y)) y = new Date (). getFullYear ();
if (isNaN (m)) m = new Date (). getmonth ();
if (isNaN (d)) d = new Date (). GetDate ();
var dt;
eval ("dt = new Date (' + y+" ', ' "+ (m-1) +" ', ' "+ D +" ') ");
return DT;
}
/**/ /**
* Date of format
* @param d The delimiter
* @param p The pattern of your date
* @author Meizz
*/
Date.prototype.format = function (style) ... {