글 수정

작성자 본인만 수정할 수 있습니다

← 홈으로
익명 · 2023.09.16 · 조회 10,034
온라인/오프라인 상태 표시 배너
<p>오프라인일 경우 오프라인입니다 배너를 출력(고정), 온라인으로 전환될 경우 온라인입니다. 배너 3초 출력</p><p><img src="https://dsclub.kr/data/editor/2309/5baa8178660c7c9f8249cc59a6d92183_1694841580_6103.jpeg" title="5baa8178660c7c9f8249cc59a6d92183_1694841580_6103.jpeg" alt="5baa8178660c7c9f8249cc59a6d92183_1694841580_6103.jpeg"></p><p><span>*온라인</span></p><p><span><br style="clear:both;"></span><img src="https://dsclub.kr/data/editor/2309/5baa8178660c7c9f8249cc59a6d92183_1694841586_1684.jpeg" title="5baa8178660c7c9f8249cc59a6d92183_1694841586_1684.jpeg" alt="5baa8178660c7c9f8249cc59a6d92183_1694841586_1684.jpeg"><br style="clear:both;">*오프라인</p><p><br></p><div>(*그누보드에 적용할 경우 head.php의 &lt;/head&gt;바로 위 또는 환경설정&gt;기본환경설정&gt;추가 script, css에 아래의 코드를 붙여넣기 하여 적용합니다.</div><div><br></div><div>[code]&lt;!--온/오프라인 배너--&gt;<div>&lt;style&gt;</div><div>&nbsp; &nbsp; .offline-banner {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; background-color: #f2f2f2;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; color: #333;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; text-align: center;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; padding: 10px;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; border-top: 1px solid #ccc;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; position: fixed;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; top: 0;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; left: 0;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; width: 100%;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; z-index: 9999;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; display: none;</div><div>&nbsp; &nbsp; }</div><div><br></div><div>&nbsp; &nbsp; .online-banner {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; background-color: #4CAF50;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; color: white;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; text-align: center;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; padding: 10px;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; border-top: 1px solid #ccc;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; position: fixed;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; top: 0;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; left: 0;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; width: 100%;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; z-index: 9999;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; display: none;</div><div>&nbsp; &nbsp; }</div><div><br></div><div>&nbsp; &nbsp; .banner-content {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; display: flex;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; align-items: center;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; justify-content: center;</div><div>&nbsp; &nbsp; }</div><div><br></div><div>&nbsp; &nbsp; .icon {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; margin-right: 10px;</div><div>&nbsp; &nbsp; }</div><div>&lt;/style&gt;</div><div>&lt;div id="status-banner" class="offline-banner"&gt;</div><div>&nbsp; &nbsp; &lt;div class="banner-content"&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &lt;div class="icon"&gt;<span style="caret-color: rgb(255, 255, 255); color: rgb(255, 255, 255); font-family: &quot;Söhne Mono&quot;, Monaco, &quot;Andale Mono&quot;, &quot;Ubuntu Mono&quot;, monospace; font-size: 14px; white-space: pre; -webkit-text-size-adjust: 100%; background-color: rgb(0, 0, 0);">📡</span>&lt;/div&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &lt;div class="status-text"&gt;오프라인입니다.&lt;/div&gt;</div><div>&nbsp; &nbsp; &lt;/div&gt;</div><div>&lt;/div&gt;</div><div>&lt;script&gt;</div><div>&nbsp; &nbsp; const statusBanner = document.getElementById('status-banner');</div><div>&nbsp; &nbsp; const statusText = document.querySelector('.status-text');</div><div><br></div><div>&nbsp; &nbsp; function checkOnlineStatus() {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; if (navigator.onLine) {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; statusText.textContent = '온라인입니다.';</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; statusBanner.classList.remove('offline-banner');</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; statusBanner.classList.add('online-banner');</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setTimeout(() =&gt; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; statusBanner.style.display = 'none';</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }, 3000);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; } else {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; statusText.textContent = '오프라인입니다.';</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; statusBanner.style.display = 'block';</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; statusBanner.classList.remove('online-banner');</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; statusBanner.classList.add('offline-banner');</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; }</div><div>&nbsp; &nbsp; checkOnlineStatus();</div><div>&nbsp; &nbsp; window.addEventListener('online', checkOnlineStatus);</div><div>&nbsp; &nbsp; window.addEventListener('offline', checkOnlineStatus);</div>&lt;/script&gt;[/code]</div>