window.addEventListener(‘load‘, function() {
var status = document.getElementById("status");
function updateOnlineStatus(event) {
var condition = navigator.onLine ? "online" : "offline";
status.className = condition;
status.innerHTML = condition.toUpperCase();
}
window.addEventListener(‘online‘, updateOnlineStatus);
window.addEventListener(‘offline‘, updateOnlineStatus);
});
时间: 2024-11-07 06:55:43