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 };