<! Doctype html> <html> <éadf> <meta charset = utf-8> <tight> Vérifiez le réseau </ title> <script type = text / javascript charset = utf-8 src = cordova.js> </cript> <script type = text / javascript charset = utf-8> document.addeventListener (deviceReady, onDeviceReady, false); fonction onDeviceReady () {checkConnection (); } // 关键代码 Fonction CheckConnection () {var NetworkState = Navigator.network.connection.type; var states = {}; états [connection.unknown] = «connexion inconnue»; States [Connection.Ethernet] = 'Ethernet Connection'; états [connection.wifi] = 'connexion wifi'; States [Connection.Cell_2g] = 'Connexion Cell 2G'; States [Connection.Cell_3g] = 'Cell 3G Connection'; States [Connection.Cell_4g] = 'Cell 4G Connection'; états [connection.none] = «pas de connexion réseau»; alert ('Type de connexion:' + états [NetworkState]); } </ script> </ head> <body onload = onload ()> <p id = props> Une boîte de dialogue rapportera l'état du réseau. </p> </ body> </html>
以上这篇使用 Phonegap 检测网络状态的方法就是小编分享给大家的全部内容了 , 希望能给大家一个参考 , 也希望大家多多支持 Vevb 武林网。