Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to detect the mobile connection is 2G/3G/WIFI using javascript

Tags:

javascript

i have a similar requirement as in link below but i have to handle it by using JavaScript. where i have to detect whether the mobile internet connection is 2g/3g or it is WIFI . based on connection i have to perform diffent operations.. note : mobile can b of any OS like andriod/ iOS/BB .. i need to handle any mobile OS.

Is there a way to detect what kind of connection I'm using ? WiFi, 3G or Ethernet?

request masters to help me with inputs. thanks :)

like image 769
user1708054 Avatar asked Sep 22 '14 06:09

user1708054


People also ask

How to check 2G or 3G network in Android?

On Android smartphones, go to settings > Network settings > mobile network. It should give you a dropdown menu of mobile standards such as 2G, 3G or LTE (4G). If you don't see 4G or LTE, then your smartphone doesn't support the standard.


1 Answers

Network Information API (This is an experimental technology):

The Network Information API provides information about the system's connection, which is in term of general connection type (e.g., 'wifi', 'cellular', etc.). This can be used to select high definition content or low definition content based on the user's connection. The entire API consists of the addition of the domxref("NetworkInformation") interface and a single property to the Navigator interface: Navigator.connection.

var connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection;
var type = connection.type;

function updateConnectionStatus() {
  alert("Connection type is change from " + type + " to " + connection.type);
}

connection.addEventListener('typechange', updateConnectionStatus);
like image 86
CD.. Avatar answered Sep 28 '22 07:09

CD..