cannot read properties of undefined (reading 'document') 채택완료
Copy
var target;
var pop_top;
var pop_left;
var cal_Day;
var oPopup =
window.createPopup();
function Calendar_Click(e) {
cal_Day = e.title;
if (cal_Day.length > 6) {
target.value = cal_Day
}
oPopup.hide();
}
function Calendar_D(obj) {
var now = obj.value.split("-");
target = obj;
pop_top = document.body.clientTop + GetObjectTop(obj) - document.body.scrollTop;
pop_left = document.body.clientLeft + GetObjectLeft(obj) - document.body.scrollLeft;
if (now.length == 3) {
Show_cal(now[0],now[1],now[2]);
} else {
now = new Date();
Show_cal(now.getFullYear(), now.getMonth()+1, now.getDate());
}
}
function Calendar_D_No_Hyphen(obj) {
var now = obj.value.split("-");
target = obj;
pop_top = document.body.clientTop + GetObjectTop(obj) - document.body.scrollTop;
pop_left = document.body.clientLeft + GetObjectLeft(obj) - document.body.scrollLeft;
if (now.length == 3) {
Show_cal_No_Hyphen(now[0],now[1],now[2]);
} else {
now = new Date();
Show_cal_No_Hyphen(now.getFullYear(), now.getMonth()+1, now.getDate());
}
}
function Calendar_W(obj) {
var now = obj.value.split("-");
target = obj;
pop_top = document.body.clientTop + GetObjectTop(obj) - document.body.scrollTop;
pop_left = document.body.clientLeft + GetObjectLeft(obj) - document.body.scrollLeft;
if (now.length == 2) {
Show_cal_W(now[0],now[1]);
} else {
now = new Date();
Show_cal_W(now.getFullYear(), now.getMonth()+1);
}
}
function Calendar_M(obj) {
var now = obj.value.split("-");
target = obj;
pop_top = document.body.clientTop + GetObjectTop(obj) - document.body.scrollTop;
pop_left = document.body.clientLeft + GetObjectLeft(obj) - document.body.scrollLeft;
if (now.length == 2) {
Show_cal_M(now[0],now[1]);
} else {
now = new Date();
Show_cal_M(now.getFullYear(), now.getMonth()+1);
}
}
function doOver(el) {
cal_Day = el.title;
if (cal_Day.length > 7) {
el.style.borderColor = "#FF0000";
}
}
function doOut(el) {
cal_Day = el.title;
if (cal_Day.length > 7) {
el.style.borderColor = "#FFFFFF";
}
}
function day2(d) { // 2자리 숫자료 변경
var str = new String();
if (parseInt(d) 10) {
str = "0" + parseInt(d);
} else {
str = "" + parseInt(d);
}
return str;
}
function Show_cal(sYear, sMonth, sDay) {
var Months_day = new Array(0,31,28,31,30,31,30,31,31,30,31,30,31)
var Month_Val = new Array("01","02","03","04","05","06","07","08","09","10","11","12");
var intThisYear = new Number(), intThisMonth = new Number(), intThisDay = new Number();
datToday = new Date(); // 현재 날자 설정
intThisYear = parseInt(sYear,10);
intThisMonth = parseInt(sMonth,10);
intThisDay = parseInt(sDay,10);
if (intThisYear == 0) intThisYear = datToday.getFullYear(); // 값이 없을 경우
if (intThisMonth == 0) intThisMonth = parseInt(datToday.getMonth(),10)+1; // 월 값은 실제값 보다 -1 한 값이 돼돌려 진다.
if (intThisDay == 0) intThisDay = datToday.getDate();
switch(intThisMonth) {
case 1:
intPrevYear = intThisYear -1;
intPrevMonth = 12;
intNextYear = intThisYear;
intNextMonth = 2;
break;
case 12:
intPrevYear = intThisYear;
intPrevMonth = 11;
intNextYear = intThisYear + 1;
intNextMonth = 1;
break;
default:
intPrevYear = intThisYear;
intPrevMonth = parseInt(intThisMonth,10) - 1;
intNextYear = intThisYear;
intNextMonth = parseInt(intThisMonth,10) + 1;
break;
}
intPPyear = intThisYear-1
intNNyear = intThisYear+1
NowThisYear = datToday.getFullYear(); // 현재 년
NowThisMonth = datToday.getMonth()+1; // 현재 월
NowThisDay = datToday.getDate(); // 현재 일
datFirstDay = new Date(intThisYear, intThisMonth-1, 1); // 현재 달의 1일로 날자 객체 생성(월은 0부터 11까지의 정수(1월부터 12월))
intFirstWeekday = datFirstDay.getDay(); // 현재 달 1일의 요일을 구함 (0:일요일, 1:월요일)
//intSecondWeekday = intFirstWeekday;
intThirdWeekday = intFirstWeekday;
datThisDay = new Date(intThisYear, intThisMonth, intThisDay); // 넘어온 값의 날자 생성
//intThisWeekday = datThisDay.getDay(); // 넘어온 날자의 주 요일
intPrintDay = 1; // 달의 시작 일자
secondPrintDay = 1;
thirdPrintDay = 1;
Stop_Flag = 0
if ((intThisYear % 4)==0) { // 4년마다 1번이면 (사로나누어 떨어지면)
if ((intThisYear % 100) == 0) {
if ((intThisYear % 400) == 0) {
Months_day[2] = 29;
}
} else {
Months_day[2] = 29;
}
}
intLastDay = Months_day[intThisMonth]; // 마지막 일자 구함
Cal_HTML = "";
Cal_HTML += "";
Cal_HTML += "";
Cal_HTML += "";
Cal_HTML += "";
Cal_HTML += " ";
for (var optYear=(intThisYear-2); optYear intLastDay) { // 입력 날짝 월말보다 크다면
Cal_HTML += "";
} else { // 입력날짜가 현재월에 해당 되면
Cal_HTML += ""+thirdPrintDay;
}
thirdPrintDay++;
if (thirdPrintDay > intLastDay) { // 만약 날짜 값이 월말 값보다 크면 루프문 탈출
Stop_Flag = 1;
}
}
Cal_HTML += "";
}
Cal_HTML += "";
if (Stop_Flag==1) break;
}
Cal_HTML += "
Copy
안녕하세요.
ie에서는 클릭시 달력이 정상 적으로 표시되지만
edge나 chome에서는
245번째줄에서
var oPopBody = oPopup.document.body;
아래와 같은 에러가 표시됩니다.
혹시 document를 대체할수 있을까요?
typeerror : cannot read properties of undefined (reading 'document')
답변 1개
채택된 답변
+20 포인트
2년 전
url에서 콘솔을 찍어보는게 정확하겠지만
제 생각으로는 element.document.body가 ifrmae이 아니고서는 올바르지 않지 않나 생각들어요
로그인 후 평가할 수 있습니다
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인