The other day I got a question asked, about geolocation.
How would I show a different phone number for my company’s website, based on the current user location?
There are many different ways to solve this problem.
Let’s analyze few of them:
2) We could instead download one of the free ip to nation database mappings that there are on the net (or use one of the ip2country services), and code some server side script that will determine the user location.
I would say that number 1 is definitely too weak.
Number 2, if I have to maintain my own ip/country database it is going to be a nightmare over time, and I don’t think there are companies (or at least I’m not aware of them) big and reliable enough that can offer a proper ip2country free webservice.
To gain further flexibility I would also add a dropdown where the default country value is the one that Google chooses as user’s position (if determined at all), and the user can interact with the dropdown if necessary, displaying a different phone number/country details.
NB: It is required a local copy of jQuery (saved as jquery.js)