javascript

<script>
    function onBridgeReady(){
        WeixinJSBridge.invoke('getNetworkType',{}, function(e){
            WeixinJSBridge.log(e.err_msg);
            //wifi[wifi网络]
            //edge[非wifi,包含3G/2G]
            //fail[网络断开连接]
            //wwan[2g或者3g]
            alert(e.subtype);
        });
    }

    if (typeof WeixinJSBridge == "undefined"){
       if( document.addEventListener ){
           document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
       }else if (document.attachEvent){
           document.attachEvent('WeixinJSBridgeReady', onBridgeReady); 
           document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
       }
    }else{
       onBridgeReady();
    }
</script>