Home > Web Front-end > JS Tutorial > js calendar compatible with FireFox supports time acquisition_time and date

js calendar compatible with FireFox supports time acquisition_time and date

WBOY
Release: 2016-05-16 18:55:36
Original
1092 people have browsed it
Copy code The code is as follows:

var cal;
var isFocus=false; //Whether it is the focus
var pickMode ={
"second":1,
"minute":2,
"hour":3,
"day":4,
"month":5,
"year":6 };

var topY=0,leftX=0; / /Custom positioning offset 2007-02-11 Added by Han Yufeng
//Select date → Added by Han Yufeng 2007-06-10, select date by ID
function 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)}
}

//Select date→ Added by Han Yufeng 2006-06-25
function SelectDate(obj,strFormat,x,y)
{

leftX =(x == null) ? leftX : x;
topY =(y == null) ? topY : y; // Custom positioning offset 2007-02-11 Added by Han Yufeng
if(document.getElementById("ContainerPanel")==null){InitContainerPanel();}
var date = new Date();
var by = date.getFullYear()-50; //Min. Value→ 50 years ago
var ey = date.getFullYear() 50; //Maximum value→ 50 years later
//cal = new Calendar(by, ey,1,strFormat); //Initialize English version , 0 is the Chinese version
cal = (cal==null) ? new Calendar(by, ey, 0) : cal; //No need to initialize every time2006-12-03 Correction
cal.DateMode =pickMode ["second"]; //Reset
if(strFormat.indexOf('s')< 0) {cal.DateMode =pickMode["minute"];}//The precision is minutes
if(strFormat .indexOf('m')< 0) {cal.DateMode =pickMode["hour"];}//The precision is time
if(strFormat.indexOf('h')< 0) {cal.DateMode =pickMode["day"];}//The precision is day
if(strFormat.indexOf('d')< 0) {cal.DateMode =pickMode["month"];}//The precision is month
if(strFormat.indexOf('M')< 0) {cal.DateMode =pickMode["year"];}//The precision is year
if(strFormat.indexOf('y')< 0 ) {cal.DateMode =pickMode["second"];}//The default precision is seconds
cal.dateFormatStyleOld = cal.dateFormatStyle;
cal.dateFormatStyle = strFormat;
cal.show(obj);
}
/**//**//**//**//**
* Return date
* @param d the delimiter
* @param p the pattern of your date
2006-06-25 Modified by Han Yufeng to the style specified by the user to confirm;
*//**//**//**
* Return Date
* @param d the delimiter
* @param p the pattern of your date
2006-06-25 Modified by Han Yufeng to be determined based on the style specified by the user;
*/
String.prototype.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 );//Day
var h = this.substring(style.indexOf('h'),style.lastIndexOf('h') 1);//Time
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;
}

/**//**
* Format date
* @param d the delimiter
* @param p the pattern of your date
* @author meizz
*<🎝>*<🎝>*<🎝>*<🎝>*<🎝>*<🎝>*
* Format date
* @param d the delimiter
* @param p the pattern of your date
* @author meizz
*/
Date.prototype.format = function(style) {
var o = {
"M " : this .getMonth() 1, //month
"d " : this.getDate(), //day
"h " : this.getHours(), //hour
"m " : this. getMinutes(), //minute
"s " : this.getSeconds(), //second
"w " : "天一二三四五六".charAt(this.getDay()), / /week
"q " : Math.floor((this.getMonth() 3) / 3), //quarter
"S" : this.getMilliseconds() //millisecond
}
if(/(y )/.test(style)) {
style = style.replace(RegExp.$1,
(this.getFullYear() "").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 Added by Han Yufeng Return the selected date <🎜>Calendar.prototype.ReturnDate = function(dt ) { <🎜>if (this.dateControl != null){this.dateControl.value = dt;} <🎜>calendar.hide(); <🎜> if(this.dateControl.onchange == null){return; }
//확인 이벤트가 발생하지 않도록 onchange를 다른 함수로 변환
var ev = this.dateControl.onchange.toString() //함수 문자열 찾기
ev = ev.substring(
       ((ev.indexOf("ValidatorOnChange();")> 0) ? ev.indexOf("ValidatorOnChange();") 20: ev.indexOf("{") 1)
          , ev.lastIndexOf( "}"));//검증 함수 제거 ValidatorOnChange();
var fun = new Function(ev); //함수 재정의
this.dateControl.changeEvent = fun; .changeEvent();//사용자 정의 ChangeEvent 함수
}

/**//**//**//**//**
* Calendar 클래스
* @param BeginYear 1990
* @param endYear 2010
* @param lang 0(중국어) | 1(영어) 자유롭게 확장 가능
* @ param dateFormatStyle "yyyy-MM-dd";
* @version 2006-04-01
* @author KimSoft (jinqinghua [at] gmail.com)
* @update
*//**//**//**
* 달력 클래스
* @param BeginYear 1990
* @param endYear 2010
* @param lang 0(중국어)|1(영어) 자유롭게 확장 가능
* @param dateFormatStyle " yyyy-MM-dd";
* @version 2006-04-01
* @author KimSoft (jinqinghua [at] gmail.com)
* @update
*/
기능 달력 (beginYear, endYear, lang, dateFormatStyle) {
this.beginYear = 1950;
this.endYear = 2050;
this.lang = 0(중국어)
this.dateFormatStyle = "yyyy-MM-dd hh:mm:ss";

if (beginYear != null && endYear != null){
this.beginYear = startYear; .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(); date.getMonth();

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

this.colors = {
"cur_word" : "#FFFFFF", //오늘 날짜 텍스트 색상
"cur_bg" : "#00FF00", //현재 날짜 셀의 배경색
"sel_bg" : "#FFCCCC", //선택한 날짜 셀의 배경색2006-12-03 한유 메이플 추가됨
"sun_word" : "#FF0000", //일요일 텍스트 색상
"sat_word" : "#0000FF", //토요일 텍스트 색상
"td_word_light" : "#333333", // 셀 텍스트 color
"td_word_dark" : "#CCCCCC", //셀 텍스트 어두운 색
"td_bg_out" : "#EFEFEF", //셀 배경색
"td_bg_over" : "#FFCC00 ", // 셀 배경색
"tr_word" : "#FFFFFF", //캘린더 헤더 텍스트 색상
"tr_bg" : "#666666", //캘린더 헤더 및 배경색
"input_border" : "#CCCCCC ", //입력컨트롤 테두리 색상
"input_bg" : "#EFEFEF" //입력컨트롤 뒷면 색상
}
/* //2008-01-29 넣어주세요 show , pickMode 판단이 필요하기 때문입니다
this.draw();
this.bindYear()
this.bindMonth()
*/
//this.changeSelect ()
//this.bindData(); //2006-12-30 Migong.Zhuanjia
}

/**//**
* 캘린더 클래스 속성(언어 팩, 자유롭게 확장 가능)
** *****
* 캘린더 클래스 속성(언어 팩, 자유롭게 확장 가능)
*/
Calendar.언어 = {
"연도" : [ [""], [""]],
"월" : [["1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월","9월","10월","11월","12월"],
["JAN","FEB","MAR"," APR","MAY","JUN"," JUL","AUG","SEP","OCT","NOV","DEC"]
],
"주" : [[" "日","一","two", "삼","사","五","六"],
["SUN","MON","TUR","WED","THU","FRI","SAT"]
],
"시" : [["시"], ["H"]],
"분" : [["분"], ["M"]],
" 초" : [["초"], ["S"]],
"지우기" : [["지우기"], ["CLS"]],
"오늘" : [["오늘" ], ["TODAY"]],
"pickTxt" : [["OK"], ["OK"]],//pickMode는 연도와 월까지 정확합니다. 오늘을 "OK"로 설정하세요.
"close " : [["Close"], ["CLOSE"]]
}

Calendar.prototype.draw = function() {
Calendar = this; var mvAry = [];//mvAry[mvAry.length] = '
' / / 12-01이 Div mvAry[mvAry.length] = '
mvAry[mvAry.length] = ' < table width="100%" border="0" cellpadding="0" cellpacing="1" style="font-size:12px;"> mvAry[mvAry.length] = ' ;'; mvAry[mvAry.length] = ' if(calendar.DateMode > pickMode["월"]){mvAry[mvAry.length] = '디스플레이:없음;';}//pickMode 精确到年时隐藏“月”
mvAry[mvAry.length] ='" name="prevMonth" type="button" id="prevMonth" value="<" />';
mvAry[mvAry.length] = ' ';
mvAry[mvAry.length] = ' 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] = ' ';
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("");

/**//**//******** 다음 코드는 Han Yufeng이 2006-12-01에 추가했습니다 ***************** 以下代码由寒羽枫 2006-12-01 添加 **********/
var obj = this.getElementById("prevMonth");
obj.onclick = 함수() {calendar.goPrevMonth(calendar);}
obj.onblur = 함수() {calendar.onblur();}
this.prevMonth= obj;

obj = this.getElementById("nextMonth");
obj.onclick = 함수() {calendar.goNextMonth(calendar);}
obj.onblur = 함수() {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 = 함수() {calendar.update(calendar);}
obj.onblur = 함수() {calendar.onblur();}
this.calendarYear = obj;

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

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

obj = this.getElementById("calendarMinute");
obj.onchange = 함수() {calendar.분 = this.options[this.selectedIndex].value;}
obj.onblur = 함수() {calendar.onblur();}
this. CalendarMinute = obj;

obj = this.getElementById("calendarSecond");
obj.onchange = 함수() {calendar.second = this.options[this.selectedIndex].value;}
obj.onblur = 함수() {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.min,calendar.second)
: new Date();//2008-01-29
캘린더 .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.언어["연도"][this. 언어], 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.언어["months"][this.lang][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] = 새 옵션(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 M = ("00" i "").substr(("" i).length);
cM.options[cM.length] = 새 옵션(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 s = ("00" i "").substr(("" i).length);
cs.options[cs.length] = 새 옵션(들, 들);
}
}

//向前一月
Calendar.prototype.goPrevMonth = function(e){
if (this.year == this.beginYear && this. 월 == 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 ){반환;}
이번 달 ;
if (this.month == 12) {
this.year ;
this.month = 0;
}
this.date = new Date(this.year, this.month, 1);
this.changeSelect();
this.bindData();
}

//SELECT 선택 상태 변경
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 작업 수를 줄이기 위해 Brick에 의해 수정됨
cy[this.date.getFullYear()-this.beginYear].selected = true
cm[this.date.getMonth()].selected =true; 🎜>
//2009-03-03 초기화 시간 값 추가
ch[this.hour].selected =true;
cM[this.분].selected =true; this .second].selected =true;
}

//연도, 월 업데이트
Calendar.prototype.update = 함수(e){
this.year = e.calendarYear. options [e.calendarYear.selectedIndex].value;//2006-12-01 수정자 Han Yufeng
this.month = e.calendarMonth.options[e.calendarMonth.selectedIndex].value
this.date; = new Date(this.year, this.month, 1);
this.bindData()
}

//데이터 바인딩 월 보기
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 Firefox에서 Migong.Zhuan에 의해 수정됨 Next 연도 오류
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 = 함수 () {return;}
tds[i].onmouseover = 함수 () {return;}
tds[i].onmouseout = 함수 () {return;}
if (i > ; dateArray.length - 1) break;
tds[i].innerHTML = dateArray[i]
if (dateArray[i] != " "){
bgColorTxt = "td_bg_out"; //2009-03-03 배경색을 저장하는 클래스
var cur = new Date()
tds[i].isToday = false
if (cur.getFullYear( ) == Calendar.date.getFullYear() && cur.getMonth() == Calendar.date.getMonth() && cur.getDate() == dateArray[i]) {
//오늘의 셀
tds[i].style.BackgroundColor = Calendar.colors["cur_bg"];
tds[i].bgColorTxt = "cur_bg";
tds[i].isToday =
}
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]) {
//선택한 셀입니다
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 날짜 선택 시 그리드를 클릭하면 값이 반환됩니다
{
calendar.ReturnDate(new Date(calendar.date.getFullYear(),
calendar.date.getMonth(),
this.innerHTML).format(calendar.dateFormatStyle))
>else
{
if(calendar.selectedDayTD != null) //2009-03-03 선택한 배경색 지우기
{
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 선택한 날짜를 기록하세요
}
}
tds[i].style.cursor ="pointer "; 2007-08-06 Han Yufeng이 추가함, 마우스가 손가락 모양으로 변함
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();}
}
}
}

//연도별, 월별 월 보기 데이터를 가져옵니다(배열 형식)
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
}
return mvArray;
}

//확장된 document.getElementById(id) meizz 트리 소스의 다중 브라우저 호환성
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) ;
{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);
//-->

위 코드를 WebCalendar.js, 페이지 호출 코드로 저장
코드 복사 코드는 다음과 같습니다.

.w3.org/1999/xhtml" >
   
본문>

< ;input type="text" value="" maxlength=" 100" id="Txt_CreateDateST01" onclick="SelectDate(이,'yyyy 연도')" readonly="true" style="width:265px;cursor:pointer" />

< input type="text" value="" maxlength="100" id="Txt_CreateDateST02" onclick="SelectDate(이번,'yyyy년 MM월')" readonly ="true" style="width:265px;cursor:pointer " />





<입력 유형 ="text" value="" maxlength="100" id="Text3" onclick="SelectDate(this,'yyyy-MM-dd hh:mm' )" readonly="true" style="width:265px;cursor :pointer" />

< ;br />






호출 방법:
1. 수신 객체: SelectDate(이번,'yyyy 연도')
2. 수신 ID: SelectDateById('Txt_CreateDateST01','yyyy 연도') 3. 매개변수 SelectDate(this,'yyyy 연도', 0,-150) 형식(참고 사례): yyyy→연도 , MM→월, 일→일, hh→24시간 형식, mm→분, ss→초
0 → 텍스트 상자 기준 가로 오프셋
-150 → 텍스트 상자 기준 세로 오프셋
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template