// HttpObject 객체를 생성하여 휙 던져준다. MakeHttpObject = function() { try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) {} // IE6 try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {} //IE5.5 try { return new XMLHttpRequest(); } catch(e) {} // IE7, Firfox alert("XMLHttpRequest를 지원하지 않는 브라우저입니다."); return null; } // 서버 시간을 받아서 Date 객체로 전달 getServerDate = function() { var xmlHttp = MakeHttpObject(); if(xmlHttp != null) { xmlHttp.open('HEAD', window.location.href.toString(),false); xmlHttp.setRequestHeader("Content-Type", "text/html"); xmlHttp.send(''); return new Date(xmlHttp.getResponseHeader("Date")); } return null; } // 서버 날짜시간을 객체로 만들어 메소드 생성 getServerDateTime = function(obj) { var Now = getServerDate(); // 서버에서 자바스크립트로 사용자에게 던져줄때 사용자 PC의 gmt에 맞추어 // 전달하므로 서버 시간 받아오는 것이 별의미가 없음 // 그래서 사용자 pc의 gmt값과 한국 gmt 값(540)을 시차를 조정하여 저장 Now.setMinutes(Now.getMinutes()+Now.getTimezoneOffset()+540); this.getUserDate = function(uDate) { Now.setYear(String(uDate).substring(0,4)); Now.setMonth(parseInt(String(uDate).substring(4,6),10) - 1); Now.setDate(String(uDate).substring(6,8)); Now.setHours(String(uDate).substring(8,10)); Now.setMinutes(String(uDate).substring(10,12)); } this.getYear = function() { return Now.getFullYear(); } this.getMonth = function() { var tmp = Now.getMonth() + 1; tmp = (tmp<10)?"0"+tmp:tmp; return tmp; } this.setDay = function(d) { Now.setDate(d); } this.getDay = function() { var tmp = Now.getDate(); tmp = (tmp<10)?"0"+tmp:tmp; return tmp; } this.getHour = function() { var tmp = Now.getHours(); tmp = (tmp<10)?"0"+tmp:tmp; return tmp; } this.getMinute = function() { var tmp = Now.getMinutes(); tmp = (tmp<10)?"0"+tmp:tmp; return tmp; } this.getFullDate = function() { return '' + this.getYear() + this.getMonth() + this.getDay(); } this.getFullDateTime = function() { return '' + this.getYear() + this.getMonth() + this.getDay() + this.getTime(); } this.getTime = function() { return '' + this.getHour() + this.getMinute(); } this.getDayNum = function() { return '' + Now.getDay(); } this.getDayName = function() { var dayNames = new Array('sun','mon','tue','wed','thu','fri','sat'); return '' + dayNames[Now.getDay()]; } this.getDayNameKor = function() { var dayNames = new Array('주일','월','화','수','목','금','토'); return '' + dayNames[Now.getDay()]; } } checkFileExisting = function(url) { var objHttp = MakeHttpObject(); var state = false; //url = "http://www.msch.or.kr/kor22/4_emp/mint1.html"; objHttp.open('GET', url, false); objHttp.onreadystatechange = function() { if(objHttp.readyState == 4) { if(objHttp.status == 200) { state = true; } else if(objHttp.status == 404) { state = false; } else { state = false; } } } objHttp.send(null); return state; }