Get client IP address via third party web service

后端 未结 7 1512
一整个雨季
一整个雨季 2020-11-27 19:02

I would like to read my ip address from the following page(http://l2.io/ip or other) using javascript to save him in my variable \"myIp\".

function getMyIP()         


        
7条回答
  •  Happy的楠姐
    2020-11-27 19:09

    A more reliable REST endpoint would be http://freegeoip.net/json/

    Returns the ip address along with the geo-location too. Also has cross-domain requests enabled (Access-Control-Allow-Origin: *) so you don't have to code around JSONP.

提交回复
热议问题