js判断网络是否连接正常

  

1 function isOnLine() {
2     var netStatus = "";
3     if (window.navigator.onLine == true) {
4         netStatus = "onLine";//网络链接正常
5     } else {
6         netStatus = "offLine";//网络连接失败
7     };
8     return netStatus;
9 };
原文地址:https://www.cnblogs.com/hermitks/p/13163021.html