How to detect country / location of visitor? [duplicate]

混江龙づ霸主 提交于 2019-12-17 05:50:33

问题


Possible Duplicate:
Location detecting techniques for IP addresses

For our website it's important to know from exactly which country our visitor is coming from.

I guess the best answer for my question would be the simple geo location feature of current browser systems, which just ask the user if the website is allowed to see his geographic location: http://dev.w3.org/geo/api/spec-source.html

but I don't want to bother visitor with questions, I would love to automatically detects the visitor's location (country should be enough.)

What's the best way to do this? - what ip database would be the best? - is the browser header trustable enough to detect his country? (en-us en-en en-ca?) What's the best solution?


回答1:


NetImpact provide a free API for geolocation lookup by IP, ProgrammableWeb also has a roundup of GeoIP lookup providers. This involves a small amount of latency while your application completes an API call (unless your application can use a non-blocking call) but is the least intrusive manner of detecting a visitor's country of origin.




回答2:


The browser header just tells you what language the user wants to see. A Spanish-speaking person on a business trip to Japan probably wants to see websites in Spanish.

I think you can use reverse-IP services to make a guess, but if it's for commerce purposes I think you have to ask the user to tell you.

Similarly with geo-location: the physical position of the computer may or may not be relevant to the needs of the user browsing the site.




回答3:


Have a look at this page on the Google Maps API: http://code.google.com/apis/maps/documentation/javascript/basics.html#DetectingUserLocation




回答4:


http://www.iplocationtools.com/samples.html also presents a good set of apis to do this. I have used their system before and they were quite reliable.



来源:https://stackoverflow.com/questions/4179000/how-to-detect-country-location-of-visitor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!