📅  最后修改于: 2022-03-11 15:02:53.209000             🧑  作者: Mango
function getStatus() {
const statusDisplay = document.getElementById("status");
statusDisplay.textContent = navigator.onLine ? "Online" : "OFFline";
if (statusDisplay.textContent === "Online") {
console.log('Online');
} else if (statusDisplay.textContent === "OFFline"){
console.log('Offline');
}
}
setInterval(getStatus, 2000);