<! doctype html> <html> <head> <메타 charset = utf-8> <title> 네트워크 확인 </title> <스크립트 유형 = 텍스트/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] = '이더넷 연결'; 상태 [connection.wifi] = 'Wi -Fi Connection'; 상태 [connection.cell_2g] = '셀 2G 연결'; 상태 [connection.cell_3g] = '셀 3G 연결'; 상태 [connection.cell_4g] = '셀 4G 연결'; 상태 [Connection.None] = '네트워크 연결 없음'; 알림 ( '연결 유형 :'+states [NetworkState]); } </script> </head> <body onload = onload ()> <p id = propss> 대화 상자가 네트워크 상태를보고합니다. </p> </body> </html>
以上这篇使用 PhoneGap ap ap, 希望能给大家一个参考, 也希望大家多多支持 vevb 武林网。