공휴일을 제외한 시간적용 ON/OFF 스크립트예제 (휴일추가가능)
제목 그대로 영업시간을 설정해두면
공휴일/설정날짜를 제외한 날에
영업시간이 되면 'ON' 아니라면 'OFF'로 되는 스크립트입니다.
(일만 추가되서 한달에한번 봐줘야합니다. 월/년 추가는 알아서 응용)
예전에 만들어놨던건데 하도 쓸데가 없어서 여기 남깁니다...누군가 쓰시겠죠?
다운로드 후 값을 변경하면서 사용해보세요.
[code]
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
</head>
<style>
*{
margin:0;
padding:0;
border:0;
text-align:center;
font-family:'돋움';
font-size:12px;
color:#898989;
font-weight:normal;
line-height:16px;
}
ul, li{
list-style:none;
}
li{
float:left;
border:0;
display:list-item;
text-align: -webkit-match-parent;
}
ul{
display: block;
-webkit-margin-before:1em;
-webkit-margin-after:1em;
-webkit-margin-start:0px;
-webkit-margin-end:0px;
-webkit-padding-start:40px;
}
p, a{
margin:0;
padding:0;
text-decoration:none;
}
#sta{
position:absolute;
height::27px;
right:50px;
}
#sta li{
margin-right:8px;
padding-right:8px;
border-right:1px solid #afafaf;
margin-top:4px;
}
#sta li.last{
border:0;
padding:0;
}
/*여기부터*/
.op span{
color:green;
}
.cl span{
color:red;
}
/*여기까지 on/off 관련 CSS */
#sta li#lastist{
clear:both;
float:right;
display:none;
background:#999;
border:1px solid black;
padding:8px;
}
</style>
<script type="text/javascript">
$(document).ready(function(e) {
function formatDate(curDate) {
var today, resultDate;
today = new Date();
resultDate = new Date(curDate);
timegap = (today - resultDate)/(60*60*1000);
return resultDate;
};
var holyweek = [];//1달에 한번 휴일 작성하는곳 ex)[15,22,16]; 없으면 []; 공란
var now = new Date();
//console.log(now);
var day = now.getDate();
//console.log(day);
var red = day == holyweek
var hour = now.getHours();
//console.log(hour);
hour=((hour>=11) && (20>hour));
//console.log(hour);
calendar = now.getDay();
//console.log(calendar);
var breakTime = 0<calendar;
//console.log(breakTime);
if(hour && breakTime && !red){
$('#sta li.last>a>p').html("온라인상담 : <span>ON</span>").removeClass().addClass('op');
}else{
$('#sta li.last>a>p').html("온라인상담 : <span>OFF</span>").removeClass().addClass('cl');
};
//console.log(hour);
var matetime=document.getElementById('#mate');
});
</script>
<body>
<ul id="sta">
<li><a href="#"><p>HOME</p></a></li>
<li><a href="#"><p>회사소개</p></a></li>
<li><a href="#"><p>사업소개</p></a></li>
<li class="last"><a href="#"><p><!-- 온라인상담 --></p></a></li>
<li id="lastist"><p><!-- 상담시간 : 11:00~20:00 --><p></li>
</ul>
</body>
</html>
[/code]
게시판 목록
개발자팁
질문은 QA에서 해주시기 바랍니다.
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 4916 | 웹서버 | 6년 전 | 2861 | ||
| 4915 | PHP |
|
6년 전 | 2174 | |
| 4914 | 웹서버 | 6년 전 | 1888 | ||
| 4913 | JavaScript | 6년 전 | 2595 | ||
| 4912 | node.js | 6년 전 | 3707 | ||
| 4911 | 기타 | 6년 전 | 4188 | ||
| 4910 | 기타 | 6년 전 | 2273 | ||
| 4909 | 기타 | 6년 전 | 1977 | ||
| 4908 | 기타 | 6년 전 | 2009 | ||
| 4907 | Mobile | 7년 전 | 2280 | ||
| 4906 | JavaScript | 7년 전 | 2282 | ||
| 4905 | 기타 | 7년 전 | 2270 | ||
| 4904 | jQuery | 7년 전 | 2511 | ||
| 4903 | PHP | 7년 전 | 5223 | ||
| 4902 | jQuery | 7년 전 | 5127 | ||
| 4901 | 기타 | 7년 전 | 2704 | ||
| 4900 | MySQL | 7년 전 | 4110 | ||
| 4899 | 기타 | 7년 전 | 2264 | ||
| 4898 | 웹서버 | 7년 전 | 2446 | ||
| 4897 | MySQL | 7년 전 | 2198 | ||
| 4896 | MySQL | 7년 전 | 2632 | ||
| 4895 | JavaScript | 7년 전 | 9767 | ||
| 4894 | 웹서버 | 7년 전 | 2354 | ||
| 4893 | 기타 | 7년 전 | 8313 | ||
| 4892 | jQuery | 7년 전 | 5677 | ||
| 4891 | 기타 | 7년 전 | 2830 | ||
| 4890 | PHP | 7년 전 | 3413 | ||
| 4889 | JavaScript | 7년 전 | 6374 | ||
| 4888 | MySQL | 7년 전 | 3132 | ||
| 4887 | MySQL | 7년 전 | 2761 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기