+
95
-

回答

<script type="text/javascript">
//以下代码请在手机端浏览器运行,电脑端会显示undefined
var connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection;

console.log(connection);
alert(connection.type);
</script>

connection.type有以下几种类型:

bluetooth //蓝牙连接  
cellular //数据连接(例如,EDGE,HSPA,LTE等)。
ethernet //以太网连接。
none //无网络连接。
mixed //用户代理正在使用多种连接类型。
other //已知的连接类型,但不是枚举连接类型之一。
unknown     //用户代理已建立网络连接,但无法或不愿意确定基础连接技术。
wifi //Wi-Fi连接。
wimax //WiMAX连接

网友回复

我知道答案,我要回答