通过window.onLine来检测,用户当前的网络状况,返回一个布尔值
window.online用户网络连接时被调用
window.offline用户网络断开时被调用

window.addEventListener("online",function(){
         alert("已经建立了网络连接")
    })
window.addEventListener("offline",function(){
         alert("已经失去了网络连接")
})
Last modification:July 12th, 2018 at 03:31 pm
If you think my article is useful to you, please feel free to appreciate