js获取Ip地址(本地Ip与外网IP)
例1,获取Ip地址代码。
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>客户端外网IP-www.jquerycn.cn</title>
</head>
<body>
IP地址是:<span id="keleyivisitorip"></span>
<script type="text/javascript" src="http://tool.keleyi.com/ip/visitoriphost/"></script>
</body>
</html>
IP地址是:114.235.53.54
例2,js获取Ip地址。
$(function(){
$(document).ready( function() {
$.getJSON( "http://smart-ip.net/geoip-json?callback=?",
function(data){
alert( data.host);
wwip=data.host;
}
);
});
});
使用方法:
一、把这个 <span id="keleyivisitorip"></span> 放到源代码中要显示IP地址的位置
二、然后,在源代码的</body>前输入:<script type="text/javascript" src="http://tool.xxx.com/ip/visitoriphost/"></script>
>>> 您可能感兴趣的文章:
php函数获取在线ip与客户端ip
PHP通过IP获取地理位置的代码
php获取远程客户端真实ip地址
php 获取用户真实IP与地理位置(淘宝IP接口)的实现代码
php通过IP获取地理位置的实例参考
php 获取网站地址的函数代码
js获取Ip地址(本地Ip与外网IP)
javascript取得IP地址与主机名的方法
php获取真实ip地址的实例分享
php通过IP获取地理位置