开发者

Discriminating between UK based and US based visitors

Apparently, $_SERVER["HTTP_ACCEPT_LANGUAGE"] can be equal to 'en-us', 'en', 'us' or 'en-gb'. Question : is this variable a reliable way of knowin开发者_如何学编程g whether a visitor is US or UK based ?

(I don't need 100% reliability but at least say 70%)


You could try using a webservice for IP-to-Country type geolocation. Try this one: http://www.hostip.info/use.html

Example Usage: http://api.hostip.info/?ip=12.215.42.19


By IP: http://www.geoplugin.com/

By Webbrowser if you have a database with countries and latitude/longitude info:

if (navigator.geolocation)
    navigator.geolocation.getCurrentPosition(getGPSLocation);

function getGPSLocation(location) {
    locationGPS=location;
    alert('location \n'+
            'latitude:'+location.coords.latitude+'\n'+
            'longitude:'+location.coords.longitude+'\n'+
            'acurracy:'+location.coords.accuracy);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜