I want get the ip address of my clients, but i only want to use pure Javascript without another library
I searched in the internet but i can't found a way to do it, I'm a student so, I have no choise, I can use only JavaScript
I found this, but it doesn't work
function myIP(){ var vi="uses java to get the users local ip number";
var yip2=java.net.InetAddress.getLocalHost();
var yip=yip2.getHostAddress();
return yip;
}
You could use telize , a third party, and make a jsonp request:
<script type="application/javascript">
function getip(json){
document.write("My IP address is : ", json.ip);
}
</script>
<script type="application/javascript" src="http://www.telize.com/jsonip?callback=getip"></script>
There is a small library which does what you are asking but I really don't know the credibility of this library.
Its called l2.io
. Here is the link for that.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.