[code]
var objCalendar=null;
var objTarget=null;
MakeCalendarFrame();
function MakeCalendarFrame(){
objCalendar=document.createElement("iframe");
objCalendar.setAttribute("id", "iCalendar")
objCalendar.setAttribute("visibility", "hidden");
objCalendar.setAttribute("position", "absolute");
objCalendar.setAttribute("width", 140);
objCalendar.setAttribute("height", 140);
objCalendar.setAttribute("zIndex", 1);
objCalendar.setAttribute("backgroundColor", "#ffffff");
objCalendar.setAttribute("borderBottomWidth",1);
objCalendar.setAttribute("borderStyle", "none");
objCalendar.setAttribute("borderColor", "#000000");
/*
objCalendar.id="iCalendar";
objCalendar.style.visibility="hidden";
objCalendar.style.position="absolute";
objCalendar.style.width=140;
objCalendar.style.height=140;
objCalendar.style.zIndex=1;
objCalendar.style.backgroundColor="#ffffff";
objCalendar.style.borderBottomWidth=1;
objCalendar.style.borderStyle="none";
objCalendar.style.borderColor="#000000";
*/
document.body.insertBefore(objCalendar);
}
function ViewCalendar(caller,target,ys,ye){
if(target==objTarget && objCalendar.style.visibility=="visible"){
objCalendar.style.visibility="hidden";
}else{
objCalendar.style.left=GetPosX(caller);
objCalendar.style.top=GetPosY(caller)+caller.offsetHeight;
objCalendar.style.visibility="visible";
//선택된 날짜 적용될 object
objTarget=target;
//변수 계산
CalcVariables(target,ys,ye);
//달력 출력
WriteCalendar();
}
}
function ChangeDate(){
//변수 재계산
ReCalcVariables();
//달력 출력
WriteCalendar();
}
function GoToday(){
intYear=intTodayYear;
intMonth=intTodayMonth;
intDay=intTodayDay;
// 해당월 1일의 요일계산, 일요일이 0
dtFirst=new Date(intYear,intMonth-1,1)
intFirstDate=dtFirst.getDay();
// 해당월의 마지막날 계산
intLastDay=GetLastDay(intYear,intMonth);
//달력 출력
WriteCalendar();
}
function ReCalcVariables(){
intYear=parseInt(iCalendar.document.getElementById("yy").value,10);
intMonth=parseInt(iCalendar.document.getElementById("mm").value,10);
// 해당월 1일의 요일계산, 일요일이 0
dtFirst=new Date(intYear,intMonth-1,1)
intFirstDate=dtFirst.getDay();
// 해당월의 마지막날 계산
intLastDay=GetLastDay(intYear,intMonth);
//해당월이 30일까지인 경우 이전에 지정되었던 날짜가 31일이면 이를 30일로 수정
if(intDay>intLastDay) intDay=intLastDay;
}
var intYear,intMonth,intDay;
var intYearStart=2000;
var intYearEnd=2010;
var intFirstDate=0;
var intLastDay=0;
var strToday=""; //오늘 표시에 쓸 날자 생성
var intTodayYear,intTodayMonth,intTodayDay;
function CalcVariables(target,ys,ye){
today=new Date();
intTodayYear=today.getFullYear();
intTodayMonth=today.getMonth()+1;
intTodayDay=today.getDate();
strYear=intTodayYear.toString();
strMonth=(intTodayMonth<10 ? "0"+intTodayMonth.toString() : intTodayMonth.toString());
strDay=(intTodayDay<10 ? "0"+intTodayDay.toString() : intTodayDay.toString());
//strToday=strYear+"-"+strMonth+"-"+strDay;
strToday=strMonth+"-"+strDay+"-"+strYear;
// 날짜 계산
if(/^\d{4}-\d{2}-\d{2}$/.test(target.value)){
arr=target.value.split(/-/g);
intYear=parseInt(arr[0],10);
intMonth=parseInt(arr[1],10);
intDay=parseInt(arr[2],10);
}else{
intYear=intTodayYear;
intMonth=intTodayMonth;
intDay=intTodayDay;
}
// select 에서 시작년월
if(/^\d+$/.test(ys)) intYearStart=parseInt(ys,10);
if(/^\d+$/.test(ye)) intYearEnd=parseInt(ye,10);
// 해당월 1일의 요일계산, 일요일이 0
dtFirst=new Date(intYear,intMonth-1,1)
intFirstDate=dtFirst.getDay();
// 해당월의 마지막날 계산
intLastDay=GetLastDay(intYear,intMonth);
}
function GetLastDay(year,month){
arrDays=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
intReturn=arrDays[month-1];
if(month==2 && IsLeapYear(year)) intReturn++;
return intReturn;
}
function IsLeapYear(year){
return ((year%4==0) && ((year%10!=0) || (year%400==0)));
}
function WriteCalendar(){
doc=iCalendar.document;
doc.open();
str="<html>"
+"<head>"
+"<style>"
+" body,table,td,a,select{font-family:굴림;}"
+"</style>"
+"<link href=\"calendar.css\" rel=\"stylesheet\" type=\"text/css\">"
+"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">"
+"</head>"
+"<body scroll=\"no\" leftmargin=\"0\" marginwidth=\"0\" topmargin=\"0\" marginheight=\"0\" onload=\"parent.ResizeWindow();\">"
+"<table cellpadding=\"0\" cellspacing=\"0\" width=\"140\">"
+"<tr align=\"center\">"
+"<td width=\"140\" height=\"26\" colspan=\"7\">"
+"<select id=\"mm\" size=\"1\" onchange=\"parent.ChangeDate();\">"
for(i=1;i<=12;i++){
if(i==intMonth) strSelected=" selected";
else strSelected="";
if(i<10) strMonth="0"+i.toString();
else strMonth=i.toString();
str+="<option value=\""+strMonth+"\""+strSelected+">"+strMonth+"</option>"
}
str+="</select>"
+"<select id=\"yy\" size=\"1\" onchange=\"parent.ChangeDate();\">"
for(i=intYearStart;i<=intYearEnd;i++){
if(i==intYear) strSelected=" selected";
else strSelected="";
str+="<option value=\""+i.toString()+"\""+strSelected+">"+i.toString()+"</option>"
}
str+="</select>"
+"</td>"
+"</tr>"
+"<tr align=\"center\" class=\"title\">"
+"<td width=\"20\" style=\"padding-right:3px;\">Sun</td>"
+"<td width=\"20\" style=\"padding-right:3px;\">Mon</td>"
+"<td width=\"20\" style=\"padding-right:3px;\">Tue</td>"
+"<td width=\"20\" style=\"padding-right:3px;\">Wed</td>"
+"<td width=\"20\" style=\"padding-right:3px;\">Thr</td>"
+"<td width=\"20\" style=\"padding-right:3px;\">Fri</td>"
+"<td width=\"20\" style=\"padding-right:3px;\">Sat</td>"
+"</tr>"
+"<tr>"
// 시작일까지 빈 공간 남기기
for(i=0;i<intFirstDate;i++){
str+="<td width=\"20\"> </td>"
}
// 7일 마다 <tr>과 </tr>을 넣기 위해
intDateCount=intFirstDate;
for(i=1;i<=intLastDay;i++){
if(intDateCount>1 && intDateCount%7==0){
str+="<tr>";
}
strDay=i.toString();
if(i==intDay){
strDay="<b>"+strDay+"</b>";
}
if(intDateCount%7==0){
strDay="<font color=\"#FF0000\">"+strDay+"</font>";
}
str+="<td width=\"20\" class=\"out\" onmouseover=\"this.className='over';\""
+" onmouseout=\"this.className='out';\"><a href=\"javascript:parent.ApplyDate("+i.toString()+");\">"+strDay+"</a></td>";
intDateCount++;
if(intDateCount%7==0){
str+="</tr>";
}
}
if(intDateCount%7!=0){
while(intDateCount%7!=0){
str+="<td width=\"20\"> </td>";
intDateCount++;
}
str+="</tr>"
}
str+="<tr class=\"bottom\">"
+"<td width=\"140\" height=\"24\" colspan=\"7\"><a"
+" href=\"javascript:parent.GoToday();\">Today "+strToday+"</a></td>"
+"</tr>"
+"</table>"
+"</body>"
+"</html>"
//taA.value=str;
doc.write(str);
doc.close();
}
function ApplyDate(day){
strYear=intYear.toString();
strMonth=(intMonth<10 ? "0"+intMonth.toString() : intMonth.toString());
strDay=(day<10 ? "0"+day.toString() : day.toString());
//strToday=strYear+"-"+strMonth+"-"+strDay;
strToday=strMonth+"-"+strDay+"-"+strYear;
objTarget.value=strToday;
// iframe 감추기
objCalendar.style.visibility="hidden";
}
function ResizeWindow(){
objBody=iCalendar.document.body;
intHeight=objBody.scrollHeight+(objBody.offsetHeight-objBody.clientHeight);
intWidth=objBody.scrollWidth+(objBody.offsetWidth-objBody.clientWidth);
iCalendar.window.resizeTo(intWidth,intHeight);
}
function GetPosX(obj){
var lngLeft=0;
if(obj.offsetParent){
while(obj.offsetParent){
lngLeft+=obj.offsetLeft;
obj=obj.offsetParent;
}
}else if(obj.x){
lngLeft+=obj.x;
}
return lngLeft;
}
function GetPosY(obj){
var lngTop=0;
if(obj.offsetParent){
while(obj.offsetParent){
lngTop+=obj.offsetTop;
obj=obj.offsetParent;
}
}else if(obj.y){
lngTop+=obj.y;
}
return lngTop;
}
과연 이넘이 왜 파폭에서만 안될까요?
Firefox 에서는 안되는 소스코드..
Who is online
Users browsing this forum: Semrush [Bot] and 2 guests