HTML onoffline 이벤트 속성은 브라우저가 오프라인 작업을 시작할 때 트리거됩니다.
구문
다음은 구문입니다 -
<tagname onoffline=”script”></tagname>
HTML 온오프라인 이벤트 Attribute-
의 예를 살펴보겠습니다.예시
<!DOCTYPE html>
<html>
<style>
body {
color: #000;
height: 100vh;
background: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%) no-repeat;
text-align: center;
}
.show {
font-size: 1.2rem;
color: #fff;
}
</style>
<body ononline="onlineFn()" onoffline="offlineFn()">
<h1>HTML onoffline/ononline Event Attribute Demo</h1>
<p style="color:#db133a;">Try to disable/enable your network.</p>
<div class="show"></div>
<script>
function onlineFn() {
alert("Hey! You are online");
}
function offlineFn() {
alert("Hey! You are offline");
}
</script>
</body>
</html> 출력

이제 네트워크를 활성화/비활성화하여 온라인/오프라인 이벤트 속성이 작동하는 방식을 관찰하십시오-
