Is there any way to detect network connection type using javascript? [duplicate]
Asked Answered
B

1

8

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.

Beestings answered 15/5, 2015 at 5:49 Comment(0)
V
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

Vita answered 15/5, 2015 at 5:57 Comment(4)
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' ?Beestings
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 itVita
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 :)Beestings
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.Cumulonimbus

© 2022 - 2024 — McMap. All rights reserved.