<! doctype html> <html> <head> <meta charset = utf-8> <title> تحقق من شبكة </title> <script type = text/javascript charset = utf-8 src = cordova.js> </script> <script type = text/javaScript charset = utf-8> document.adDeventListener (deviceready ، ondeviceready ، false) ؛ وظيفة ondeviceready () {checkConnection () ؛ } // 关键代码 وظيفة checkConnection () {var networkState = navigator.network.connection.type ؛ var states = {} ؛ الدول [connection.unknown] = "اتصال غير معروف" ؛ الدول [connection.ethernet] = 'Ethernet connection' ؛ الدول [connection.wifi] = 'wifi connection' ؛ الحالات [connection.cell_2g] = 'cell 2g connection' ؛ الحالات [connection.cell_3g] = 'cell 3g connection' ؛ الحالات [connection.cell_4g] = 'cell 4g connection' ؛ الدول [connection.none] = "لا يوجد اتصال شبكة" ؛ التنبيه ('نوع الاتصال:'+حالات [NetworkState]) ؛ } </script> </head> <body onload = onload ()> <p id = props> سيقوم مربع حوار بإبلاغ حالة الشبكة. </p> </body> </html>
以上这篇使用 phonegap 检测网络状态的方法就是小编分享给大家的全部内容了 , 希望能给大家一个参考 , 也希望大家多多支持 vevb 武林网。