通过window.onLine来检测,用户当前的网络状况,返回一个布尔值window.online用户网络连接时被调用window.offline用户网络断开时被调用window.addEventListener("online",function(){ alert("已经建立了网络连接") }) window.addEventListener("offline",function(){ alert("已经失去了网络连接") }) Last modification:July 12, 2018 © Allow specification reprint Support Appreciate the author AliPayWeChat Like If you think my article is useful to you, please feel free to appreciate