如何使用javascript获取本地IP地址? [英] How to get local ip address using javascript?

查看:119
本文介绍了如何使用javascript获取本地IP地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Everyone,



有没有办法在javascript中获取访问者*本地* IP地址或客户端计算机IP地址?



我的意思是他的局域网地址如192.168.1.x,而不是他的常规IP地址,如123.168.xxx.xxx。



我找到了几种尝试这样做的方法,但它们要么给我外部(常规)IP地址,要么给出127.0.0.1,它并没有真正告诉我任何事情。我需要本地机器IP地址。



我使用的Javascript之一是:

 < script     type   =  application / javascript >  
function getip( json){
alert(json.ip);
}
< / script >
< script type = application / javascript src = http:// jsonip.appspot.com/?callback=getip\"> < / script >





提前谢谢。

解决方案

通过快速搜索,我找到了以下链接:检查这些 [ ^ ], [ ^ ], [ ^ ]

Hello Everyone,

Is there a way to get the visitors *local* IP-address or Client machine IP address in javascript?

I mean his LAN address like 192.168.1.x, not his regular IP-address like 123.168.xxx.xxx.

I found several approaches that attempt to do this, but they either give me the external (regular) IP address, or they give 127.0.0.1 which doesn't really tell me anything. I need the local machine IP address.

One of Javascript i used is:

<script type="application/javascript">
function getip(json) {
alert(json.ip);
}
</script>
<script type="application/javascript" src="http://jsonip.appspot.com/?callback=getip"> </script>



Thanks in advance.

解决方案

With a quick search I found these links : Check these[^], [^], [^]


这篇关于如何使用javascript获取本地IP地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆