0

I'm using javascript to lookup a user's location based on the IP address. It works great for everything except cellular networks (which, unfortunately, is the bulk of my site's visitors). For cellular connections, the location is often off by 100 miles or more.

A stripped down version of the site is here: http://autopilothomelistings.com/ab/geoip13.html

I'm trying to figure out a way to determine if a visitor to my site is on a wireless connection or on Wifi/LAN, so that I can display alternate content depending on the connection type, but I haven't found a suitable answer. I can check for the device or browser, but these are not helpful, since a 'mobile' device can either be on wifi (which results in an accurate location) or on cellular (which is inaccurate).

I found a few threads that were somewhat relevant, but didn't ultimately provide any help:

1.) Thread discussing Apple's Reachability class: How to identify internet connection type and it's current speed

2.) Thread discussing navigator.connection: How do I check connection type (WiFi/LAN/WWAN) using HTML5/JavaScript? - which look promising in theory, but when I looked at the documentation here: https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation.connection - it appears to unsupported by the major browsers.

3.) Thread that uses javascript to determine connection speed: How to Determine Connection Type in JavaScript

Any ideas are greatly appreciated. I'm hoping there is an easy way to check the connection type on the client-side.

Community
  • 1
  • 1
jhohman
  • 37
  • 1
  • 9
  • Did you look into getting the browser to tell you where the user is? https://www.mozilla.org/en-US/firefox/geolocation/ – spender May 21 '14 at 01:07
  • 1
    If the bulk of your users are using mobile phone...why can't you use their GPS (if they have one)? It's very likely that most of them will be accessing you're site with a smartphone – Leo May 21 '14 at 01:08
  • Yes, @jfriend00, some cellular connections are faster than WiFi, but I only care about the connection type since cellular gives me inaccurate location, and WiFi gives me accurate location. If I could detect a cellular connection, I would serve content that is not dependent on the visitor's location. – jhohman May 21 '14 at 01:24
  • @splendor, I haven't looked into geolocation from the browser, but I will look into it now. This link provides some useful info: - I didn't even know this was a possibility. This looks like it may work for me: – jhohman May 21 '14 at 01:27

1 Answers1

2

Directly speaking you cannot.

There is currently a Draft in w3.org Here, which gives informtion,It is experimental.But at present only selected & update browsers support that method.

Mozilla has even not defined it in its compatibility report, but you can see its parent class compatibility Here, which shows that this method is still far behind.

There are still some methods available like iOS,Windows APP, PhoneGAP (They support because they have built an application. Here is information on API)