온라인/오프라인 상태 표시 배너 > 코딩게시판

본문 바로가기
사이트 내 전체검색

코딩게시판

온라인/오프라인 상태 표시 배너

페이지 정보

작성자 익명 이름으로 검색  (192.2)
조회 153회 작성일 23-09-16 14:24

본문

신고

오프라인일 경우 오프라인입니다 배너를 출력(고정), 온라인으로 전환될 경우 온라인입니다. 배너 3초 출력

5baa8178660c7c9f8249cc59a6d92183_1694841580_6103.jpeg

*온라인


5baa8178660c7c9f8249cc59a6d92183_1694841586_1684.jpeg
*오프라인


(*그누보드에 적용할 경우 head.php의 </head>바로 위 또는 환경설정>기본환경설정>추가 script, css에 아래의 코드를 붙여넣기 하여 적용합니다.

[code]<!--온/오프라인 배너-->
<style>
    .offline-banner {
        background-color: #f2f2f2;
        color: #333;
        text-align: center;
        padding: 10px;
        border-top: 1px solid #ccc;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        z-index: 9999;
        display: none;
    }

    .online-banner {
        background-color: #4CAF50;
        color: white;
        text-align: center;
        padding: 10px;
        border-top: 1px solid #ccc;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        z-index: 9999;
        display: none;
    }

    .banner-content {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .icon {
        margin-right: 10px;
    }
</style>
<div id="status-banner" class="offline-banner">
    <div class="banner-content">
        <div class="icon">📡</div>
        <div class="status-text">오프라인입니다.</div>
    </div>
</div>
<script>
    const statusBanner = document.getElementById('status-banner');
    const statusText = document.querySelector('.status-text');

    function checkOnlineStatus() {
        if (navigator.onLine) {
            statusText.textContent = '온라인입니다.';
            statusBanner.classList.remove('offline-banner');
            statusBanner.classList.add('online-banner');
            setTimeout(() => {
                statusBanner.style.display = 'none';
            }, 3000);
        } else {
            statusText.textContent = '오프라인입니다.';
            statusBanner.style.display = 'block';
            statusBanner.classList.remove('online-banner');
            statusBanner.classList.add('offline-banner');
        }
    }
    checkOnlineStatus();
    window.addEventListener('online', checkOnlineStatus);
    window.addEventListener('offline', checkOnlineStatus);
</script>[/code]
좋아요0 싫어요0
url 복사카카오톡 공유라인 공유페이스북 공유트위터 공유

댓글목록

profile_image
Total 173건 1 페이지
코딩게시판 목록
번호 제목 작성자 조회수 좋아요 싫어요 날짜
173 tak2 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 13 0 0 2일 전
172 익명 이름으로 검색 12 0 0 3일 전
171 익명 이름으로 검색 18 0 0 3일 전
170 익명 이름으로 검색 19 0 0 3일 전
169 익명 이름으로 검색 19 0 0 3일 전
168 익명 이름으로 검색 17 0 0 3일 전
167 tak2 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 12 0 0 3일 전
166 tak2 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 51 2 0 1개월 전
165 tak2 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 181 1 0 17일 전
164 이름으로 검색 225 1 0 17일 전
163 익명 이름으로 검색 182 0 0 18일 전
열람중 익명 이름으로 검색 154 0 0 18일 전
161
.php 확장자 댓글1
익명 이름으로 검색 228 0 0 18일 전
160 익명 이름으로 검색 205 0 0 21일 전
159
.sql 확장자 댓글1
익명 이름으로 검색 168 0 0 21일 전

검색


모바일버전서비스이용약관개인정보처리방침이메일 무단수집 거부
Copyright ©www.dsclub.kr All rights reserved.