文章详细
ajax获取客户端ip及城市地址
 2013/12/4 15:01:52 评论:0人 阅读次数:12748

最近做的一个反馈的效果中有一个是 js判断浏览器类型版本及系统类型 现在准备加一个IP及城市所在直一并写入数据库。这样查看起来更方便了解用户所处的环境。

效果如下图:

ajax获取客户端ip及城市地址

好了,贴代码吧!代码比较简单。如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>ajax获取客户端ip及城市地址</title>    
    <script src="http://www.86y.org/js/jq.js" type="text/javascript"></script>
    <script>    
    function getadress(){       
		$.ajax({
		 url: "http://chaxun.1616.net/s.php?type=ip&output=json",
		   dataType:"jsonp",
		   success: function(data){	
			 alert(data.Ip+"-"+data.Isp);
			 //ipstr=data.Ip+"-"+data.Isp;      	         
		   }
		});
	}
    </script>
</head>
<body>
    <a href="javascript:getadress();">ajax获取客户端ip及城市地址</a>
</body>
</html>

(完)

如需转载请注明出处:http://www.86y.org/art_detail.aspx?id=645【ajax获取客户端ip及城市地址】幸凡学习网
0
 
相关文章
推荐文章
Created By Charry-May 3,2010
粤ICP备10093478号-1
顶部