1、js取得IP地址的方法一
<script src="http://pv.sohu.com/cityjson?ie=utf-8"></script> <script type="text/javascript"> document.write(returnCitySN["cip"]+','+returnCitySN["cname"]) </script>
2、js取得IP地址的方法二
<script language="javascript" type="text/javascript" src="http://fw.qq.com/ipaddress">
</script>
<script>document.write("你的IP是:"+IPData[0]+",来自:"+IPData[2]);
</script>
3、js取得ip地址的方法三,腾讯IP,转UTF-8:
<script type="text/javascript" src="http://fw.qq.com/ipaddress" charset="gb2312"></script>
$(document).ready(function() {
$("#ip").val(IPData[0]);
$("#add").val(IPData[2]);
})
4、js取得IP地址的方法四
<script>
var fso = new ActiveXObject("Scripting.FileSystemObject");
var wsh = new ActiveXObject("WScript.Shell");
wsh.Run("command.com /c ipconfig /all > C:\\ip.txt");
var f = fso.OpenTextFile("C:\\ip.txt");
var s = f.ReadAll();
f.Close();
alert(s.match(/IP Address(\. )+\: ((\d{1,3}\.){3}(\d{1,3}))/i)[2])
</script>