IP to Location using Javascript

后端 未结 13 1411
死守一世寂寞
死守一世寂寞 2020-11-27 03:46




        
13条回答
  •  借酒劲吻你
    2020-11-27 03:57

    You can submit the IP you receive to an online geolocation service, such as http://www.geoplugin.net/json.gp?ip=&jsoncallback=, then including the source it returns which will run the function you specify in jsoncallback with the geolocation information.

    Alternatively, you may want to look into HTML5's geolocation features -- you can see a demo of it in action here. The advantage of this is that you do not need to make requests to foreign servers, but it may not work on browsers that do not support HTML5.

提交回复
热议问题