스크립트 계절별 이미지

스크립트 계절별 이미지

QA

스크립트 계절별 이미지

본문

특정일과 시간별 이미지 변경 스크립트로 아래와 같은 스크립트를 사용중입니다.

 

<script language="JavaScript"> 

var date = new Date(); 
var tYear = <?=date('Y')?>; 
var tMonth = <?=date('m')?>; 
var tDate = <?=date('d')?>; 
var tDay = <?=date('w')?>; 
var tHour = <?=date('h')?>; 
var Today = tYear + "-" + tMonth + "-" + tDate; 
var Holidays = { 
"2014-8-15" : "/img/qna_notice_01.png", 
"2014-9-8" : "/img/qna_notice_01.png", 
"2014-9-9" : "/img/qna_notice_01.png" 


function _time(f, t) { 
return (tHour >= f && tHour < t) ? true : false; 


if(Holidays[Today]) { 
document.write("<img src='" + Holidays[Today] + "' />"); 
} else { 
if((tDay == 6 || tDay == 0) && tHour >= 1) { 
document.write('<img src="/img/qna_notice_01.png">'); 
} else { 
if(_time(0, 11) == true) { 
document.write('<img src="/img/qna_notice_02.png">'); 
} else if(_time(11, 12) == true) { 
document.write('<img src="/img/qna_notice_04.png">'); 
} else if(_time(12, 13) == true) { 
document.write('<img src="/img/qna_notice_03.png">'); 
} else if(_time(13, 18) == true) { 
document.write('<img src="/img/qna_notice_04.png">'); 
} else if(_time(18, 24) == true) { 
document.write('<img src="/qna_notice_02.png">'); 


</script>

 

위 스크립트를 계절별로

11월~2월

3월 ~6월

7월~ 8월

9월~10월

이렇게 몇월부터 몇월까지 이미지를 자동 변경하면서 보여주려면 어찌 수정해야할까요?
능력자님들 알려주세요..ㅠㅠ

이 질문에 댓글 쓰기 :

답변 2

소스를 다 말씀드리긴 힘들고 저 tMonth 값을 가지고 이용하시면 될거 같습니다. 소스를 잘 모르시니 일단 if 문으로 모든 1~12월에 해당하는 이미지를 넣어보세요

답변을 작성하시기 전에 로그인 해주세요.
전체 934
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT