————————————————————————————
<script type="text/javascript" language="javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
//初始化函数
function init(){
//判断google的城市是否可用
if( google.loader.ClientLocation.address.city) {
//通过google的api获取城市信息
var locationCity = google.loader.ClientLocation.address.city;
alert(locationCity);//展示城市的信息结果
}
}
</script>
——————————————————————————
<body onload="init();">
</body>
——————————————————————————