ホームページ >ウェブフロントエンド >jsチュートリアル >FireFox互換のjsカレンダーが時刻取得_日時をサポート

FireFox互換のjsカレンダーが時刻取得_日時をサポート

WBOY
WBOYオリジナル
2016-05-16 18:55:361092ブラウズ
コードをコピー コードは次のとおりです:

var cal;
var isFocus=false; //フォーカスかどうか
var pickMode ={
"秒":1,
"分":2,
"時":3,
"日":4,
"月":5,
"年":6 };

var topY=0,leftX=0 ; / /カスタム位置オフセット 2007-02-11 Han Yufeng によって追加されました
//日付を選択 → Han Yufeng によって追加されました 2007-06-10、ID によって日付を選択
関数 SelectDateById(id,strFormat ,x,y )
{
var obj = document.getElementById(id);
if(obj == null){return false;}
obj.focus()
if (obj.onclick) != null){obj.onclick();}
else if(obj.click != null){obj.click();}
else{SelectDate(obj,strFormat,x, y)}
}

//日付の選択→ Han Yufeng により追加 2006-06-25
function SelectDate(obj,strFormat,x,y)
{

leftX =( x == null) ? leftX : x;
topY =(y == null) ? topY : y; // カスタム位置オフセット 2007 年 2 月 11 日追加
if(document.getElementById(") ContainerPanel")==null){InitContainerPanel();}
var date = new Date();
var by = date.getFullyear()-50; //最小値→ 50 年前
var ey = date.getFull Year() 50; //最大値→ 50 年後
//cal = new Calendar(by, ey,1,strFormat) //英語版を初期化、0 は中国語版
cal = (cal==null) ? new Calendar(by, ey, 0) : cal; //毎回初期化する必要はありません2006-12-03 Correction
cal.DateMode =pickMode ["second"] / /Reset
if(strFormat.indexOf('s')if(strFormat .indexOf('m' )if(strFormat.indexOf('h')if(strFormat.indexOf('d')< 0) {cal.DateMode =pickMode["month"];}//精度は月です
if (strFormat.indexOf('M')< 0) {cal.DateMode =pickMode["year"];}//精度は年です
if(strFormat.indexOf('y')< 0 ) { cal.DateMode =pickMode["second"];} //デフォルトの精度は秒です。
cal.dateFormatStyleOld = cal.dateFormatStyle;
cal.show(obj); 🎜>}
/**//**//**//**//**
* 日付を返します
* @param d 区切り文字
* @param p 日付のパターン
2006-06-25 Han Yufeng によってユーザーが指定したスタイルに変更されました確認するため
*//**//**//**
* 返却日
* @param d区切り文字
* @param p 日付のパターン
2006-06-25 ユーザーが指定したスタイルに基づいて決定されるように Han Yufeng によって変更されました。 toDate = function(style) {
var y = this.substring(style.indexOf('y'),style.lastIndexOf('y') 1);//year
var M = this.substring( style .indexOf('M'),style.lastIndexOf('M') 1);//month
var d = this.substring(style.indexOf('d'),style.lastIndexOf('d') 1 );//日
var h = this.substring(style.indexOf('h'),style.lastIndexOf('h') 1);//時間
var m = this.substring(style .indexOf('m'),style.lastIndexOf('m') 1);//point
var s = this.substring(style.indexOf('s'),style.lastIndexOf('s') 1 ) ;//Seconds

if(s == null ||s == "" || isNaN(s)) {s = new Date().getSeconds();}
if(m = = null ||m == "" || isNaN(m)) {m = new Date().getMinutes();}
if(h == null ||h == "" || isNaN( h )) {h = new Date().getHours();}
if(d == null ||d == "" || isNaN(d)) {d = new Date().getDate() ; }
if(M == null ||M == "" || isNaN(M)) {M = new Date().getMonth() 1;}
if(y == null || y == "" || isNaN(y)) {y = new Date().getFullyear();}
var dt ;
eval ("dt = new Date('" y "', '" ( M-1) "','" d "','" h "','" m "','" s "')");
return dt
}

/**//**
* 日付の形式
* @param d 区切り文字
* @param p 日付のパターン
* @author meizz
*<🎝>*<🎝>*<🎝>*<🎝>*<🎝>*<🎝>*
* 日付の形式
* @param 区切り文字
* @param p 日付のパターン
* @author meizz
*/
Date.prototype.format = function(style) {
var o = {
"M " : this .getMonth() 1, //月
"d " : this.getDate(), //日
"h " : this.getHours(), //時間
"m " : this. getMinutes(), //分
"s " : this.getSeconds(), //秒
"w " : "天一二三四五六".charAt(this.getDay()), / /週
"q " : Math.floor((this.getMonth() 3) / 3), //四半期
"S" : this.getMilliseconds() //ミリ秒
}
if(/(y )/.test(style)) {
style = style.replace(RegExp.$1,
(this.getFull Year() "").substr(4 - RegExp.$1.length) );
}
for(var k in o){
if(new RegExp("(" k ")").test(style)){
style = style.replace(RegExp .$1,
RegExp.$1.length == 1 ? o[k] :
("00" o[k]).substr(("" o[k]).length)); >}
}
return style;
}
<🎜>//2007-09-14 Han Yufeng により追加 選択された日付を返します <🎜>Calendar.prototype.ReturnDate = function(dt ) { <🎜>if (this.dateControl != null){this.dateControl.value = dt;} <🎜>calendar.hide() <🎜> if(this.dateControl.onchange == null){return; }
//Convert onchange to other functions to avoid triggering verification events
var ev = this.dateControl.onchange.toString(); //Find the string of the function
ev = ev.substring(
       ((ev.indexOf("ValidatorOnChange();")> 0) ? ev.indexOf("ValidatorOnChange();") 20: ev.indexOf("{") 1)
          , ev.lastIndexOf ("}"));//Remove the validation function ValidatorOnChange();
var fun = new Function(ev); //Redefine the function
this.dateControl.changeEvent = fun;
this.dateControl .changeEvent();//Trigger custom changeEvent function
}

/**//**//**//**//**
* Calendar class
* @param beginYear 1990
* @param endYear 2010
* @param lang 0 (Chinese) | 1 (English) Can be freely expanded
* @ param dateFormatStyle "yyyy-MM-dd";
* @version 2006-04-01
* @author KimSoft (jinqinghua [at] gmail.com)
* @update
*//**//**//**
* Calendar class
* @param beginYear 1990
* @param endYear 2010
* @param lang 0(Chinese)|1(English) Freely expandable
* @param dateFormatStyle "yyyy-MM-dd";
* @version 2006-04-01
* @author KimSoft (jinqinghua [at] gmail.com)
* @update
*/
function Calendar(beginYear, endYear, lang, dateFormatStyle) {
this.beginYear = 1950;
this.endYear = 2050;
this.lang = 0; //0(Chinese) | 1(English)
this.dateFormatStyle = "yyyy-MM-dd hh:mm:ss";

if (beginYear != null && endYear != null){
this.beginYear = beginYear;
this.endYear = endYear;
}
if (lang != null){
this.lang = lang
}

if (dateFormatStyle != null){
this.dateFormatStyle = dateFormatStyle
}

this.dateControl = null;
this.panel = this.getElementById("calendarPanel");
this.container = this.getElementById(" ContainerPanel");
this.form = null;

this.date = new Date();
this.year = this.date.getFullYear();
this.month = this.date.getMonth();

this.day = this.date.getDate();
this.hour = this.date.getHours();
this.minute = this. date.getMinutes();
this.second = this.date.getSeconds();

this.colors = {
"cur_word" : "#FFFFFF", //Today’s date text color
"cur_bg" : "#00FF00", //The background color of the current date cell
"sel_bg" : "#FFCCCC", //The background color of the selected date cell2006-12-03 Han Yu Maple added
"sun_word" : "#FF0000", //Sunday text color
"sat_word" : "#0000FF", //Saturday text color
"td_word_light" : "#333333", // Cell text color
"td_word_dark" : "#CCCCCC", //Cell text dark color
"td_bg_out" : "#EFEFEF", //Cell background color
"td_bg_over" : "#FFCC00 ", //Cell background color
"tr_word" : "#FFFFFF", //Calendar header text color
"tr_bg" : "#666666", //Calendar header and background color
"input_border" : "#CCCCCC", //The border color of the input control
"input_bg" : "#EFEFEF" //The back color of the input control
}
/* //2008-01-29 Put it in show , because the pickMode judgment needs to be made
this.draw();
this.bindYear();
this.bindMonth();
*/
//this.changeSelect();
//this.bindData(); //2006-12-30 Commented by Migong.Zhuanjia
}

/**//**
* Calendar class attributes (language pack, freely expandable)
*******
* Calendar class attributes (language pack, freely extendable)
*/
Calendar.language = {
"year" : [ [""], [""]],
"months" : [["January", "February", "March", "April", "May", "June", "July","August","September","October","November","December"],
["JAN","FEB","MAR"," APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"]
],
"weeks" : [[" "日","一","二","三","四","五","六"],
["SUN","MON","TUR","WED","THU ","FRI","SAT"]
],
"hour" : [["hour"], ["H"]],
"minute" : [["minute"], ["M"]],
"second" : [["seconds"], ["S"]],
"clear" : [["clear"], ["CLS"]],
"today" : [["Today"], ["TODAY"]],
"pickTxt" : [["OK"], ["OK"]],//pickMode is accurate to the year and month Make today "OK"
"close" : [["Close"], ["CLOSE"]]
} Calendar.prototype.draw = function() { calendar = this; var mvAry = []; //mvAry[mvAry.length] = '
'; / /Because cannot be nested, 2006-12-01 changed to Div mvAry[mvAry.length] = '
mvAry[mvAry.length] = ' '; mvAry[mvAry.length] = ' '; mvAry[mvAry.length] = ' ';
mvAry[mvAry.length] = ' ';
mvAry[mvAry.length] = ' ';
mvAry[mvAry.length] = ' ';
mvAry[mvAry.length] = '
if(calendar.DateMode > pickMode["month"]){mvAry[mvAry.length] = 'display:none;';}//pickMode 精确到年时隐藏“月”
mvAry[mvAry.length] ='" name="prevMonth" type="button" id="prevMonth" value="<" />
if(calendar.DateMode > pickMode["month"]){mvAry[mvAry.length] = 'display:none;';}//pickMode 精确到年时隐藏“月”
mvAry[mvAry.length] ='" name="nextMonth" type="button" id="nextMonth" value=">" />
';
mvAry[mvAry.length] = ' mvAry[mvAry.length] = '" border="0" cellpadding="3" cellspacing="1">';
mvAry[mvAry.length] = ' ';
for(var i = 0; i < 7; i++) {
mvAry[mvAry.length] = ' ';
}
mvAry[mvAry.length] = ' ';
for(var i = 0; i < 6;i++){
mvAry[mvAry.length] = ' ';
for(var j = 0; j < 7; j++) {
if (j == 0){
mvAry[mvAry.length] = ' ';
} else if(j == 6) {
mvAry[mvAry.length] = ' ';
} else {
mvAry[mvAry.length] = ' ';
}
}
mvAry[mvAry.length] = ' ';
}

//2009-03-03 添加的代码,放置时间的行
mvAry[mvAry.length] = ' mvAry[mvAry.length] = '">';

mvAry[mvAry.length] = '
' + Calendar.language["weeks"][this.lang][i] + '
';
mvAry[mvAry.length] = ' ' + Calendar.language["hour"][this.lang];
mvAry[mvAry.length] = 'mvAry[mvAry.length] = '">' + Calendar.language["minute"][this.lang]+'';
mvAry[mvAry.length] = 'mvAry[mvAry.length] = '">'+ Calendar.language["second"][this.lang]+'';
mvAry[mvAry.length] = '
';
//mvAry[mvAry.length] = ' ';
mvAry[mvAry.length] = '
';
mvAry[mvAry.length] = ' ';
mvAry[mvAry.length] = ' mvAry[mvAry.length] = '" style="border: 1px solid ' + calendar.colors["input_border"] + ';background-color:' + calendar.colors["input_bg"] + ';width:60px;height:20px;font-size:12px;cursor:pointer"/>';
mvAry[mvAry.length] = ' ';
mvAry[mvAry.length] = '
';

mvAry[mvAry.length] = '
';
this.panel.innerHTML = mvAry.join("");

/**//**//******** The following code was added by Han Yufeng on 2006-12-01 ***************** 以下代码由寒羽枫 2006-12-01 添加 **********/
var obj = this.getElementById("prevMonth");
obj.onclick = function () {calendar.goPrevMonth(calendar);}
obj.onblur = function () {calendar.onblur();}
this.prevMonth= obj;

obj = this.getElementById("nextMonth");
obj.onclick = function () {calendar.goNextMonth(calendar);}
obj.onblur = function () {calendar.onblur();}
this.nextMonth= obj;

obj = this.getElementById("calendarClear");
obj.onclick = function ()
{ calendar.ReturnDate(""); /*calendar.dateControl.value = "";calendar.hide();*///2007-09-14 由寒羽枫注释
}
this.calendarClear = obj;

obj = this.getElementById("calendarClose");
obj.onclick = function () {calendar.hide();}
this.calendarClose = obj;

obj = this.getElementById("calendarYear");
obj.onchange = function () {calendar.update(calendar);}
obj.onblur = function () {calendar.onblur();}
this.calendarYear = obj;

obj = this.getElementById("calendarMonth");
with(obj)
{
onchange = function () {calendar.update(calendar);}
onblur = function () {calendar.onblur();}
}this.calendarMonth = obj;

obj = this.getElementById("calendarHour");
obj.onchange = function () {calendar.hour = this.options[this.selectedIndex].value;}
obj.onblur = function () {calendar.onblur();}
this.calendarHour = obj;

obj = this.getElementById("calendarMinute");
obj.onchange = function () {calendar.minute = this.options[this.selectedIndex].value;}
obj.onblur = function () {calendar.onblur();}
this.calendarMinute = obj;

obj = this.getElementById("calendarSecond");
obj.onchange = function () {calendar.second = this.options[this.selectedIndex].value;}
obj.onblur = function () {calendar.onblur();}
this.calendarSecond = obj;

obj = this.getElementById("calendarToday");
obj.onclick = function () {
var today = (calendar.DateMode != pickMode["day"]) ?
new Date(calendar.year,calendar.month,calendar.day,calendar.hour,calendar.minute,calendar.second)
: new Date();//2008-01-29
calendar.ReturnDate(today.format(calendar.dateFormatStyle));
}
this.calendarToday = obj;
}

//年份下拉框绑定数据
Calendar.prototype.bindYear = function() {
var cy = this.calendarYear;//2006-12-01 由寒羽枫修改
cy.length = 0;
for (var i = this.beginYear; i <= this.endYear; i ){
cy.options[cy.length] = new Option(i Calendar.language["year"][this.lang], i);
}
}

//月份下拉框绑定数据
Calendar.prototype.bindMonth = function() {
var cm = this.calendarMonth;//2006-12-01 由寒羽枫修改
cm.length = 0;
for (var i = 0; i < 12; i ){
cm.options[cm.length] = new Option(Calendar.language["months"][this.lang][i], i);
}
}

//小时下拉框绑定数据
Calendar.prototype.bindHour = function() {
var ch = this.calendarHour;
if(ch.length > 0){return;}//2009-03-03 不需要重新绑定,提高性能
//ch.length = 0;
var h;
for (var i = 0; i < 24; i ){
h = ("00" i "").substr(("" i).length);
ch.options[ch.length] = new Option(h, h);
}
}

//分钟下拉框绑定数据
Calendar.prototype.bindMinute = function() {
var cM = this.calendarMinute;
if(cM.length > 0){return;}//2009-03-03 不需要重新绑定,提高性能
//cM.length = 0;
var M;
for (var i = 0; i < 60; i ){
M = ("00" i "").substr(("" i).length);
cM.options[cM.length] = new Option(M, M);
}
}

//秒钟下拉框绑定数据
Calendar.prototype.bindSecond = function() {
var cs = this.calendarSecond;
if(cs.length > 0){return;}//2009-03-03 不需要重新绑定,提高性能
//cs.length = 0;
var s;
for (var i = 0; i < 60; i ){
s = ("00" i "").substr(("" i).length);
cs.options[cs.length] = new Option(s, s);
}
}

//向前一月
Calendar.prototype.goPrevMonth = function(e){
if (this.year == this.beginYear && this.month == 0){return;}
this.month--;
if (this.month == -1) {
this.year--;
this.month = 11;
}
this.date = new Date(this.year, this.month, 1);
this.changeSelect();
this.bindData();
}

//向后一月
Calendar.prototype.goNextMonth = function(e){
if (this.year == this.endYear && this.month == 11){return;}
this.month ;
if (this.month == 12) {
this.year ;
this.month = 0;
}
this.date = new Date(this.year, this.month, 1);
this.changeSelect();
this.bindData();
}

//Change the SELECT selected status
Calendar.prototype.changeSelect = function() {
var cy = this.calendarYear;//2006-12-01 Modified by Han Yufeng
var cm = this.calendarMonth;
var ch = this.calendarHour;
var cM = this.calendarMinute;
var cs = this.calendarSecond;
//2006-12-30 by Migong. Modified by Brick to reduce the number of operations
cy[this.date.getFullYear()-this.beginYear].selected = true;
cm[this.date.getMonth()].selected =true;

//2009-03-03 Added, initialization time value
ch[this.hour].selected =true;
cM[this.minute].selected =true;
cs[this .second].selected =true;
}

//Update year, month
Calendar.prototype.update = function (e){
this.year = e.calendarYear.options [e.calendarYear.selectedIndex].value;//2006-12-01 Modified by Han Yufeng
this.month = e.calendarMonth.options[e.calendarMonth.selectedIndex].value;
this.date = new Date(this.year, this.month, 1);
//this.changeSelect();
this.bindData();
}

//Bind data To the month view
Calendar.prototype.bindData = function () {
var calendar = this;
if(calendar.DateMode >= pickMode["month"]){return;}//2008- 01-29
// var dateArray = this.getMonthViewArray(this.date.getYear(), this.date.getMonth());
//2006-12-30 Modified by Migong.Zhuan in Firefox Next year error
var dateArray = this.getMonthViewArray(this.date.getFullYear(), this.date.getMonth());
var tds = this.getElementById("calendarTable").getElementsByTagName("td" );
for(var i = 0; i < tds.length; i ) {
tds[i].style.backgroundColor = calendar.colors["td_bg_out"];
tds[i] .onclick = function () {return;}
tds[i].onmouseover = function () {return;}
tds[i].onmouseout = function () {return;}
if (i > dateArray.length - 1) break;
tds[i].innerHTML = dateArray[i];
if (dateArray[i] != " "){
tds[i]. bgColorTxt = "td_bg_out"; //2009-03-03 class that saves the background color
var cur = new Date();
tds[i].isToday = false;
if (cur.getFullYear( ) == calendar.date.getFullYear() && cur.getMonth() == calendar.date.getMonth() && cur.getDate() == dateArray[i]) {
//is today’s cell
tds[i].style.backgroundColor = calendar.colors["cur_bg"];
tds[i].bgColorTxt = "cur_bg";
tds[i].isToday = true;
}
if(calendar.dateControl != null )
{
cur = calendar.dateControl.value.toDate(calendar.dateFormatStyle);
if (cur.getFullYear() == calendar.date. getFullYear() && cur.getMonth() == calendar.date.getMonth()&& cur.getDate() == dateArray[i]) {
//It is the selected cell
calendar.selectedDayTD = tds[i];
tds[i].style.backgroundColor = calendar.colors["sel_bg"];
tds[i].bgColorTxt = "sel_bg";
}
}
tds[i].onclick = function () {
if(calendar.DateMode == pickMode["day"]) //2009-03-03 When selecting a date, click the grid to return the value
{
calendar.ReturnDate(new Date(calendar.date.getFullYear(),
calendar.date.getMonth(),
this.innerHTML).format(calendar.dateFormatStyle));
}
else
{
if(calendar.selectedDayTD != null) //2009-03-03 Clear the selected background color
{
calendar.selectedDayTD.style.backgroundColor =(calendar .selectedDayTD.isToday)? calendar.colors["cur_bg"] : calendar.colors["td_bg_out"];
}
this.style.backgroundColor = calendar.colors["sel_bg"];
calendar .day = this.innerHTML;
calendar.selectedDayTD = this; //2009-03-03 Record the selected day
}
}
tds[i].style.cursor ="pointer "; //2007-08-06 Added by Han Yufeng, the mouse turns into a finger shape
tds[i].onmouseover = function () {
this.style.backgroundColor = calendar.colors["td_bg_over" ];
}
tds[i].onmouseout = function () {
if(calendar.selectedDayTD != this) {
this.style.backgroundColor = calendar.colors[this.bgColorTxt] ;}
}
tds[i].onblur = function () {calendar.onblur();}
}
}
}

//According to the year, Month gets the month view data (array form)
Calendar.prototype.getMonthViewArray = function (y, m) {
var mvArray = [];
var dayOfFirstDay = new Date(y, m, 1). getDay();
var daysOfMonth = new Date(y, m 1, 0).getDate();
for (var i = 0; i < 42; i ) {
mvArray[i] = " ";
}
for (var i = 0; i < daysOfMonth; i ){
mvArray[i dayOfFirstDay] = i 1;
}
return mvArray;
}

//Extended document.getElementById(id) Multi-browser compatibility from meizz tree source
Calendar.prototype.getElementById = function(id){
if (typeof(id ) != "string" || id == "") return null;
if (document.getElementById) return document.getElementById(id);
if (document.all) return document.all(id) ;
try {return eval(id);} catch(e){ return null;}
}

//扩展 object.getElementsByTagName(tagName)
Calendar.prototype.getElementsByTagName = function(object, tagName){
if (document.getElementsByTagName) return document.getElementsByTagName(tagName);
if (document.all) return document.all.tags(tagName);
}

//取得HTML控件绝对位置
Calendar.prototype.getAbsPoint = function (e){
var x = e.offsetLeft;
var y = e.offsetTop;
while(e = e.offsetParent){
x += e.offsetLeft;
y += e.offsetTop;
}
return {"x": x, "y": y};
}

//显示日历
Calendar.prototype.show = function (dateObj, popControl) {
if (dateObj == null){
throw new Error("arguments[0] is necessary")
}
this.dateControl = dateObj;
var now = new Date();
this.date = (dateObj.value.length > 0) ? new Date(dateObj.value.toDate(this.dateFormatStyle)) : now.format(this.dateFormatStyle).toDate(this.dateFormatStyle) ;//2008-01-29 寒羽枫添加 → 若为空则根据dateFormatStyle初始化日期

if(this.panel.innerHTML==""||cal.dateFormatStyleOld != cal.dateFormatStyle)//2008-01-29 把构造表格放在此处,2009-03-03 若请示的样式改变,则重新初始化
{
    this.draw();
    this.bindYear();
    this.bindMonth();
    this.bindHour();
    this.bindMinute();
    this.bindSecond();
}
this.year = this.date.getFullYear();
this.month = this.date.getMonth();
this.day = this.date.getDate();
this.hour = this.date.getHours();
this.minute = this.date.getMinutes();
this.second = this.date.getSeconds();
this.changeSelect();
this.bindData();

if (popControl == null){
popControl = dateObj;
}
var xy = this.getAbsPoint(popControl);
//this.panel.style.left = xy.x + "px";
//this.panel.style.top = (xy.y + dateObj.offsetHeight) + "px";
this.panel.style.left = (xy.x + leftX)+ "px"; //由寒羽枫 2007-02-11 修改 → 加入自定义偏移量
this.panel.style.top = (xy.y + topY + dateObj.offsetHeight) + "px";

//由寒羽枫 2006-06-25 修改 → 把 visibility 变为 display,并添加失去焦点的事件 //this.setDisplayStyle("select", "hidden");
//this.panel.style.visibility = "visible";
//this.container.style.visibility = "visible";
this.panel.style.display = "";
this.container.style.display = "";

if( !this.dateControl.isTransEvent)
{
    this.dateControl.isTransEvent = true;
    /* 已写在返回值的时候 ReturnDate 函数中,去除验证事件的函数
    this.dateControl.changeEvent = this.dateControl.onchange;//将 onchange 转成其它函数,以免触发验证事件
    this.dateControl.onchange = function()
    {if(typeof(this.changeEvent) =='function'){this.changeEvent();}}*/
    if(this.dateControl.onblur != null){
    this.dateControl.blurEvent = this.dateControl.onblur;}//2007-09-14 保存主文本框的 onblur ,使其原本的事件不被覆盖
    this.dateControl.onblur = function()
    {calendar.onblur();if(typeof(this.blurEvent) =='function'){this.blurEvent();}
    }
}

this.container.onmouseover = function(){isFocus=true;}
this.container.onmouseout = function(){isFocus=false;}
}

//隐藏日历
Calendar.prototype.hide = function() {
//this.setDisplayStyle("select", "visible");
//this.panel.style.visibility = "hidden";
//this.container.style.visibility = "hidden";
this.panel.style.display = "none";
this.container.style.display = "none";
isFocus=false;
}

//焦点转移时隐藏日历 → 由寒羽枫 2006-06-25 添加
Calendar.prototype.onblur = function() {
if(!isFocus){this.hide();}
}

//以下由寒羽枫 2007-07-26 修改 → 确保日历容器节点在 body 最后,否则 FireFox 中不能出现在最上方
function InitContainerPanel() //初始化容器
{
    var str = '';
if(document.all)
{
str = '';
}
var div = document .createElement("div");
div.innerHTML = str;
div.id = "ContainerPanel";
div.style.display ="none";
document.body.appendChild( div);
}//Call calendar.show(dateControl, popControl);
//-->

Save the above code as WebCalendar.js, page calling code
Copy code The code is as follows:

.w3.org/1999/xhtml" >