通过javascript或jquery确定用户的Internet连接类型 [英] Determine user's internet connection type via javascript or jquery

查看:109
本文介绍了通过javascript或jquery确定用户的Internet连接类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用javascript根据IP地址查找用户的位置.它适用于除蜂窝网络(不幸的是,这是我的网站访问者的大部分)以外的所有内容.对于蜂窝连接,该位置通常相距100英里或更远.

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.

网站的精简版在这里: http://autopilothomelistings.com/ab/geoip13.html

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

我正在尝试确定一种方法来确定我的站点的访问者是通过无线连接还是通过Wifi/LAN,以便我可以根据连接类型显示备用内容,但是我没有找到一个合适的答案.我可以检查设备或浏览器,但是它们没有帮助,因为移动"设备可以在wifi上(这将导致准确的位置)或在蜂窝网络上(不准确).

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.)讨论Apple可达性类的线程: 如何识别互联网连接类型及其当前速度

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

2.)讨论navigator.connection的线程: 如何检查连接类型(WiFi /LAN/WWAN)使用HTML5/JavaScript吗?-理论上看似有希望,但当我在此处查看文档时:

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.)使用javascript确定连接速度的线程: 如何确定JavaScript中的连接类型

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.

推荐答案

直接说不能.

w3.org中目前有一个草稿此处,它提供了信息,这是实验性的.但目前仅选择&更新浏览器支持该方法.

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甚至没有在兼容性报告中定义它,但是您可以看到其父类兼容性

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.

还有一些可用的方法,例如iOS,Windows APP,PhoneGAP(它们之所以支持,是因为它们已经构建了一个应用程序.

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

这篇关于通过javascript或jquery确定用户的Internet连接类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆