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.
Asked
Active
Viewed 1.6k times
1 Answers
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

Community
- 1
- 1

Sumit Surana
- 1,554
- 2
- 14
- 28
-
Thanks for the reply. But have you tried the Network Information API in mozilla browser. When I tried the example of 'Detecting connection changes' on the documentation I'm getting error like 'TypeError: connection is undefined'. May be because its a 'experimental technology' ? – Prasad May 15 '15 at 06:14
-
Yes you are right more over it is not totally stabilized yet so there will be issues in implementing Network_Information_API and also check the compatibility of the mobile/desktop browser before you use it – Sumit Surana May 15 '15 at 06:26
-
Interesting ! its working fine in mobile browsers. I'm using Motog 2nd Gen mobile device and checked in Chrome, Opera, Mozilla browsers, its working perfectly fine. Lets hope soon it will get stabilized in all platform :) – Prasad May 15 '15 at 07:08
-
navigator.connection, which is the answer given inside this link does not work on Mac OS and Firefox/Chrome on Windows. I do not recommend this solution. – Ian Steffy Mar 01 '16 at 08:08