使用js获取手机的网络状态


connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection;
根据connection.type判断网络类型,connection.type有以下几种类型:
bluetooth      //蓝牙连接  
cellular       //数据连接(例如,EDGE,HSPA,LTE等)。
ethernet       //以太网连接。
none           //无网络连接。
mixed          //用户代理正在使用多种连接类型。
other          //已知的连接类型,但不是枚举连接类型之一。
unknown      //用户代理已建立网络连接,但无法或不愿意确定基础连接技术。
wifi           //Wi-Fi连接。
wimax          //WiMAX连接
详情参考:
https://developer.mozilla.org/zh-CN/docs/Web/API/Network_Information_API
https://developer.mozilla.org/zh-CN/docs/Web/API/Navigator/connection
http://wicg.github.io/netinfo/


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM