<! DocType html> <html> <head> <meta charset = utf-8> <tites> Netzwerk überprüfen </title> <script type = text/javaScript charset = utf-8 src = cordova.js> </script> <script type = text/javaScript charset = utf-8> document.addeventListener (deviceready, ondeviceready, false); Funktion ONDEVICEREADAY () {CheckConnection (); } // 关键代码 Funktion checkConnection () {var networkState = navigator.network.connection.type; var States = {}; States [Connection.UnNown] = 'Unbekannte Verbindung'; States [Connection.Ethernet] = 'Ethernet Connection'; States [Connection.wifi] = 'WiFi Connection'; States [Connection.cell_2g] = 'Cell 2G Connection'; States [Connection.cell_3g] = 'Cell 3G Connection'; States [Connection.cell_4g] = 'Cell 4G Connection'; States [Connection.none] = 'keine Netzwerkverbindung'; alert ('Verbindungstyp:'+States [NetworkState]); } </script> </head> <body onload = onload ()> <p id = props> Ein Dialogfeld meldet den Netzwerkstatus. </p> </body> </html>
以上这篇使用 Telefonegap 检测网络状态的方法就是小编分享给大家的全部内容了 , 希望能给大家一个参考 , 也希望大家多多支持 vevb 武林网。