I would like to know is there any way to check if user is connected from 2G, 3G, 4G, or WiFi using javascript. As of my knowledge only Mozilla provides a Network Information API which helps to detect general connection type like 'wifi', 'cellular' etc.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
This question already has answers here:
Closed 5 months ago.
回答1:
It is a wrong approach to expose your network to javascript. Anyways for your better understanding please go through the below link
How do I check connection type (WiFi/LAN/WWAN) using HTML5/JavaScript?
And there is one that can be of help but only supports mozilla and for the info you can visit the below link
https://developer.mozilla.org/en-US/docs/Web/API/Network_Information_API