Khi trình duyệt web bắt đầu hoạt động ngoại tuyến, onoffline trình kích hoạt thuộc tính. Bạn có thể thử chạy mã sau để triển khai onoffline thuộc tính -
Ví dụ
<!DOCTYPE html>
<html>
<body ononline = "onlineFunc()" onoffline = "offlineFunc()">
<script>
function onlineFunc() {
alert ("Working online!");
}
function offlineFunc() {
alert ("Workinf offline!");
}
</script>
<p>Got o the web browser menu bar and click the File menu. Select "Work Offline" and toggle between online and offline.</p>
</body>
</html>