JS
<!--下面一个开放的JS中有一个方法可以获取当前IP地址-->
<script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>
<script type="text/javascript">
$(function (){
alert(1111);
var ip=""; //所属的IP
var cityAndAddress=""; //登录的地区
$(function () {
//获取IP,页面加载的时候自动执行
ip=returnCitySN["cip"];
$.ajax({
url: 'http://api.map.baidu.com/location/ip?ak=xxxx',
type: 'POST',
dataType: 'jsonp',
success:function(data) {
//获取城市
cityAndAddress=data.content.address_detail.province + "," + data.content.address_detail.city;
//alert("IP:"+ip);
//alert("cityAndAddress:"+cityAndAddress);
$("#address").text(cityAndAddress);
$("#ip").text(ip);
}
});
})
})
</script>