应用phonegap检验互联网情况的方式

日期:2020-10-13 类型:科技新闻 

关键词:ps网页版在线制作,静态网页制作方法,微云网页版,怎么制作一个网页,django网页模板

案例以下:

<!DOCTYPE html> 
<html> 
  
    <head> 
        <meta charset="UTF⑻"> 
        <title>Check NetWork</title> 
  
        <script type="text/javascript" charset="UTF⑻" src="cordova.js"></script> 
        <script type="text/javascript" charset="UTF⑻"> 
          document.addEventListener("deviceready", onDeviceReady, false); 
            function onDeviceReady() { 
                checkConnection(); 
            } 
              
            //重要编码 
            function checkConnection(){ 
                var networkState=navigator.network.connection.type; 
                var states={}; 
                states[Connection.UNKNOWN]='Unknown connection'; 
                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]='No network connection'; 
                  
                alert('Connection type: '+states[networkState]); 
            } 
              
        </script> 
    </head> 
  
    <body onload="onLoad()"> 
        <p id="props"> A dialog box will report the network state.</p> 
    </body> 
  
</html>

以上这篇应用phonegap检验互联网情况的方式便是网编共享给大伙儿的所有內容了,期待能给大伙儿1个参照,也期待大伙儿多多适用脚本制作之家。