📜  为网站提供灰色离线比例 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:08.548000             🧑  作者: Mango

代码示例1
window.addEventListener('online', function(e) {
    // add your logic to update the UI when online
    console.log("You are online");
    document.body.style.filter = 'grayscale(0)';
}, false);

window.addEventListener('offline', function(e) {
    // add your logic to update the UI when offline
    console.log("You are offline");
    document.body.style.filter = 'grayscale(1)';
}, false);