<! Doctype html> <html> <head> <meta charset = utf-8> <title> verifique la red </title> <script type = text/javaScript charset = utf-8 src = cordova.js> </script> <script type = text/javaScript charset = utf-8> document.adDeventListener (DeviceReady, OnDeviceReady, False); function onDeviceReady () {checkconnection (); } // 关键代码 function checkconnection () {var networkState = navigator.network.connection.type; estates var = {}; Estados [Connect.unknown] = 'Conexión desconocida'; Estados [Connection.Ethernet] = 'Conexión Ethernet'; Estados [Connection.wifi] = 'Conexión wifi'; Estados [Connect.Cell_2g] = 'Cell 2g Conexión'; estados [Connection.Cell_3g] = 'Cell 3G Connection'; estados [Connect.Cell_4g] = 'Cell 4g Conexión'; Estados [Connection.None] = 'Sin conexión de red'; alerta ('Tipo de conexión:'+estados [networkState]); } </script> </head> <body onload = onload ()> <p id = props> un cuadro de diálogo informará el estado de red. </p> </body> </html>
以上这篇使用 PhoneGap 检测网络状态的方法就是小编分享给大家的全部内容了 , 希望能给大家一个参考 也希望大家多多支持 也希望大家多多支持 VEVB 武林网。