<! Doctype html> <html> <head> <meta charset = utf-8> <title> Verificação da rede </ititle> <script type = text/javascript charset = utf-8 src = cordova.js> </script> <script type = text/javascript charset = utf-8> document.addeventListener (deviceReady, OnDevicEready, false); function ONDeviceady () {checkConnection (); } // 关键代码 função checkConnection () {var networkState = Navigator.network.Connection.Type; var estados = {}; estados [Connection.unknown] = 'conexão desconhecida'; estados [Connection.ethernet] = 'Ethernet Connection'; estados [conexão.wifi] = 'conexão wifi'; estados [conexão.Cell_2G] = 'Cell 2G Connection'; estados [Connection.Cell_3G] = 'Cell 3G Connection'; estados [conexão.Cell_4G] = 'Cell 4G Connection'; estados [conexão.None] = 'Nenhuma conexão de rede'; alerta ('Tipo de conexão:'+estados [NetworkState]); } </script> </ad Head> <corpo onload = onLload ()> <p id = props> Uma caixa de diálogo relatará o estado da rede. </p> </body> </html>以上这篇使用 PhoneGap 检测网络状态的方法就是小编分享给大家的全部内容了 , 希望能给大家一个参考 , 也希望大家多多支持 VEVB 武林网。