강의 컨설팅 트레이닝 무료진단 무료책자 마케팅편지 마케팅정보공유 다이어리 서비스제휴 고객센터

페이지 한개에서 모든것을 해결할 수 있는 탭메뉴 스크립트
작성자 : 99 단국강토
등록날짜 : 2009.02.09 09:51
1,406

잘 응용하면 하나의 문서로 여러페이지를 보여줄 수 있는 유용한 스크립트 입니다


<!------ [1단계] 아래의 스크립트 소스를 <head></head> 사이에 복사 해 넣으세요 ------->

<style type="text/css">
/**탭메뉴박스 설정**/
#tablist{
padding: 3px 0;
margin-left: 0;
margin-bottom: 0;
margin-top: 0.1em;
font: bold 12px Verdana;
}

#tablist li{
list-style: none;
display: inline;
margin: 0;
}

#tablist li a{
padding: 3px 0.5em;
margin-left: 3px;
border: 1px solid #778;
border-bottom: none;
background: white;
}

#tablist li a:link, #tablist li a:visited{
color: navy;
}

#tablist li a.current{
background: lightyellow;
}

/**내용이 보여질 박스 설정**/
#tabcontentcontainer{
width: 400px;
padding: 20px;
border: 1px solid black;
}

.tabcontent{
display:none;
}

</style>

<script type="text/javascript">

var initialtab=[1, "sc1"] // 처음 시작될 탭의 ID

function cascadedstyle(el, cssproperty, csspropertyNS){
if (el.currentStyle)
return el.currentStyle[cssproperty]
else if (window.getComputedStyle){
var elstyle=window.getComputedStyle(el, "")
return elstyle.getPropertyValue(csspropertyNS)
}
}

var previoustab=""

function expandcontent(cid, aobject){
if (document.getElementById){
highlighttab(aobject)
detectSourceindex(aobject)
if (previoustab!="")
document.getElementById(previoustab).style.display="none"
document.getElementById(cid).style.display="block"
previoustab=cid
if (aobject.blur)
aobject.blur()
return false
}
else
return true
}

function highlighttab(aobject){
if (typeof tabobjlinks=="undefined")
collecttablinks()
for (i=0; i<tabobjlinks.length; i++)
tabobjlinks[i].style.backgroundColor=initTabcolor
var themecolor=aobject.getAttribute("theme")? aobject.getAttribute("theme") : initTabpostcolor
aobject.style.backgroundColor=document.getElementById("tabcontentcontainer").style.backgroundColor=themecolor
}

function collecttablinks(){
var tabobj=document.getElementById("tablist")
tabobjlinks=tabobj.getElementsByTagName("A")
}

function detectSourceindex(aobject){
for (i=0; i<tabobjlinks.length; i++){
if (aobject==tabobjlinks[i]){
tabsourceindex=i
break
}
}
}

function do_onload(){
var cookiecheck=window.get_cookie && get_cookie(window.location.pathname).indexOf("|")!=-1
collecttablinks()
initTabcolor=cascadedstyle(tabobjlinks[1], "backgroundColor", "background-color")
initTabpostcolor=cascadedstyle(tabobjlinks[0], "backgroundColor", "background-color")
if (typeof enablepersistence!="undefined" && enablepersistence && cookiecheck){
var cookieparse=get_cookie(window.location.pathname).split("|")
var whichtab=cookieparse[0]
var tabcontentid=cookieparse[1]
expandcontent(tabcontentid, tabobjlinks[whichtab])
}
else
expandcontent(initialtab[1], tabobjlinks[initialtab[0]-1])
}

if (window.addEventListener)
window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
window.attachEvent("onload", do_onload)
else if (document.getElementById)
window.onload=do_onload

</script>


<!-------- 아래의 스크립트는 새로고침 시에도 현재페이지 상태를 유지시키기 위한 코드입니다 ----->

<script type="text/javascript">

var enablepersistence=true // 현재페이지 유지시에는 true, 아니면 false

function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function savetabstate(){
document.cookie=window.location.pathname+"="+tabsourceindex+"|"+previoustab
}

window.onunload=savetabstate

</script>

</head>

<body>

<!------ [2단계] 아래의 스크립트를 원하는 위치에 붙여 넣으세요 ---------------------->

<ul id="tablist">
<li><a href="#" class="current" onClick="return expandcontent('sc1', this)">첫번째메뉴</a></li>
<li><a href="#" onClick="return expandcontent('sc2', this)" theme="#EAEAFF">두번째메뉴</a></li>
<li><a href="#" onClick="return expandcontent('sc3', this)" theme="#FFE6E6">세번째메뉴</a></li>
<li><a href="#" onClick="return expandcontent('sc4', this)" theme="#DFFFDF">네번째메뉴</a></li>
</ul>

<DIV id="tabcontentcontainer">

        <div id="sc1" class="tabcontent">
        첫번째 탭 메뉴의 내용에 들어갈 구문을 입력 하세요
        </div>

        <div id="sc2" class="tabcontent">
        두번째 탭 메뉴의 내용에 들어갈 구문을 입력 하세요
        </div>

        <div id="sc3" class="tabcontent">
        세번째 탭 메뉴의 내용에 들어갈 구문을 입력 하세요
        </div>

        <div id="sc4" class="tabcontent">
        네번째 탭 메뉴의 내용에 들어갈 구문을 입력 하세요
        </div>


</DIV>


<!------ 여기까지 입니다 ----------> 

[출처]  빛남이

"쇼핑몰·홈페이지·오픈마켓
블로그·페이스북·이메일 등의 각종 마케팅 글쓰기,
각종 광고, 영업, 판매, 제안서, 전단지
반응율 3배×10배 이상 높이는 마법의 8단계 공식"
자세히보기

Comments

번호 제목 글쓴이 날짜 조회
2985 Table 태그 (2) 99 단국강토 02.09 2240
2984 테이블 응용 99 단국강토 02.09 2352
2983 프레임 tag-프레임(1) 99 단국강토 02.09 2149
2982 프레임(2) 99 단국강토 02.09 2147
2981 form tag-form (1) 99 단국강토 02.09 1991
2980 form(2) 99 단국강토 02.09 1802
2979 form-(4) 99 단국강토 02.09 2267
2978 아름다운글 올리는 방법 5 마퀴 태그 99 단국강토 02.09 2300
2977 이미지의 태그 처리 99 단국강토 02.09 2253
2976 글쓰기/FIELDSET source 99 단국강토 02.09 2531
2975 블로그 영상시, 나도 만들어 볼까? 99 단국강토 02.09 2291
2974 동적 테이블 생성 DHTML 99 단국강토 02.09 2986
2973 table,tr,td 의 innerHTML 속성으로 좀 가꾸놀기 99 단국강토 02.09 3923
2972 CSS를 활용한 INPUT FORM의 커스트마이징 기법 99 단국강토 02.09 2887
2971 테이블 테두리를 가늘게 하는 확실한 팁 99 단국강토 02.09 2271
2970 스타일시트를 적용시키는 3가지 방법 99 단국강토 02.09 2059
2969 cursor:hand 을 cursor:pointer 로 교체요 ^^ 99 단국강토 02.09 2266
2968 ID attribute selector 99 단국강토 02.09 1496
2967 폼테그쓸때 테이블정렬이 잘안될때 쓰이는 css 99 단국강토 02.09 1602
2966 홈페이지 제작시 사용되는 CSS 정리 99 단국강토 02.09 1342
2965 부드럽게 펼쳐지는 콤보박스형 메뉴 99 단국강토 02.09 1673
2964 [CSS]스타일시트로 배경그림 고정시키기 99 단국강토 02.09 1676
2963 아이프레임 일부기능 대체할 수 있는 박스 99 단국강토 02.09 3230
열람중 페이지 한개에서 모든것을 해결할 수 있는 탭메뉴 스크립트 99 단국강토 02.09 1407
2961 [CSS]글씨 크기-줄 간격 조절해서 보기 좋은 문서 만들기 99 단국강토 02.09 3308
2960 아이프레임 일부기능 대체할 수 있는 박스 99 단국강토 02.09 1308
2959 백그라운드 반복없이 한번만 넣기 99 단국강토 02.09 1861
2958 JAVASCRIPT + DOM 을 이용한 데이터 검색 99 단국강토 02.09 2785
2957 JAVASCRIPT + DOM 을 이용한 데이터 검색 99 단국강토 02.09 1961
2956 DOM 참조(JavaScript이용) 99 단국강토 02.09 1621
마케팅
특별 마케팅자료
다운로드 마케팅자료
창업,경영
기획,카피,상품전략
동기부여,성취