how to check website offline status in js
https://developer.mozilla.org/en-US/docs/Web/API/NavigatorOnLine/Online_and_offline_events
navigator.onLine
const online = window.navigator.onLine;
window.addEventListener('load', function() {
var status = document.getElementById("status");
var log = document.getElementById("log");
function updateOnlineStatus(event) {
var condition = navigator.onLine ? "online" : "offline";
status.className = condition;
status.innerHTML = condition.toUpperCase();
log.insertAdjacentHTML("beforeend", "Event: " + event.type + "; Status: " + condition);
}
window.addEventListener('online', updateOnlineStatus);
window.addEventListener('offline', updateOnlineStatus);
});
https://bug336359.bmoattachments.org/attachment.cgi?id=220609
http://html5-demos.appspot.com/static/navigator.onLine.html
https://caniuse.com/#feat=online-status
offline demo
https://alligator.io/react/whats-new-in-react-16.9/
Service Workers
©xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!