本文介绍了如何在客户端站点中检测浏览器国家?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现以下网站即使在私有模式下也可以检测到我的国家和货币





是否可以在客户网站上实现?导航器?

解决方案

有多个选项可以确定区域设置。按照有用程度从高到低依次为:


  1. 查找 IP地址,,例如。这是请求来自的位置,即,如果一个美国人在意大利度假并使用瑞典VPN,它将返回瑞典

只能在服务器的帮助下完成。主要优点是它非常可靠。准确度是免费服务的国家或地区,付费服务的城市或地区。


  1. 查找准确的位置使用。使用瑞典VPN在意大利度假的美国人将注册为意大利。

答案将非常准确,通常不超过1000万美元。原则上,它可以在客户端运行,尽管您可能希望在服务器上执行坐标->国家/地区查询。主要缺点是,并非所有设备都具有GPS或WiFi位置,并且通常需要用户的明确同意。


  1. 查看标头(或在服务器的帮助下),并提取语言环境信息。使用瑞典VPN在意大利度假的美国人将注册为美国。

缺点是,此设置非常容易更改。例如,世界各地讲英语的人可能更喜欢 zh-CN 设置,以避免使用机器翻译的文本。在现代浏览器上(截至目前,尚未编写IE / Edge,而仅使用Safari 11+),您也可以请求。


  1. navigator.languages 标头的第一个元素。 navigator.languages的所有注意事项都适用。最重要的是,有时这些信息可能只是没有任何语言环境的语言(即 en 而不是 en-US )。


  2. 使用其他第三方服务。例如,如果用户通过单点登录系统(如Facebook connect)登录,则可以请求用户的家乡。此信息通常非常不可靠,并且需要第三方。



I found the following website can detect my country and currency even in the private mode

http://www.innisfreeworld.com/

It records in cookie, How do it do that?

Is that possible fulfill in client site ? navigator?

解决方案

There are multiple options to determine the locale. In descending order of usefulness, these are:

  1. Look up the IP address, with an IP geolocation service like Maxmind GeoIP. This is the location the request is coming from, i.e. if an American vacations in Italy and uses a Swedish VPN, it will return Sweden.

It can only be done with the help of the server. The main advantage is that it's very reliable. The accuracy will be country or region for free services, city or region for paid ones.

  1. Look up the precise location on Earth from the browser with the geolocation API. An American vacationing in Italy using a Swedish VPN will register as Italy.

The answer will be very precise, usually no more than 10m off. In principle, it could work client-side, although you may want to perform the coordinate -> country lookup on the server. The main disadvantages are that not all devices have either GPS or WiFi position, and that it generally requires explicit user consent.

  1. Look in the Accept-Language header on the server (or with the help of the server), and extract the locale information. An American vacationing in Italy using a Swedish VPN will register as USA.

The downside is that this is a setting that's extremely easy to change. For instance, English speakers around the world may prefer en-US settings in order to avoid machine-translated text. On modern browsers (as of writing not IE/Edge, and only Safari 11+), you can also request navigator.languages.

  1. navigator.language is the first element of the navigator.languages header. All of the considerations of navigator.languages apply. On top, this information can sometimes be just the language without any locale (i.e. en instead of en-US).

  2. Use another, third-party service. For instance, if the user signs in via a Single-Sign-On system such Facebook connect, you can request the hometown of the user. This information is typically very unreliable, and requires a third party.

这篇关于如何在客户端站点中检测浏览器国家?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 00:20