问问题
409 次
2 回答
3
<a href="" id="location">GPS Location</a>
<script>
function onGeoSuccess(event)
{
document.getElementById("Latitude").value = event.coords.latitude;
document.getElementById("Longitude").value = event.coords.longitude;
document.getElementById("location").href = "page.htm?Lat=" + event.coords.latitude + "&Long=" + event.coords.longitude;
}
</script>
于 2012-07-27T20:03:31.190 回答
0
Zoltan 让我朝着正确的方向开始 - 不能让它太拉,不得不在身体上增加一个负载。
现在我正在尝试重定向到该网址,但它不会与 javascript 重定向一起使用...
谢谢佐尔坦
<script type="text/javascript">
// Get a single location update
function getLocationConstant()
{
if(navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(onGeoSuccess,onGeoError,{enableHighAccuracy:true,maximumAge:0});
} else {
alert("Your browser or device doesn't support Geolocation");
}
}
// If we have a successful location update
function onGeoSuccess(event)
{
document.getElementById("Latitude").value = event.coords.latitude;
document.getElementById("Longitude").value = event.coords.longitude;
document.getElementById("location").href = "track.cfm?track=s&Lat=" + event.coords.latitude + "&Long=" + event.coords.longitude;
var redirectUrl = "track.cfm?track=s&Lat=" + event.coords.latitude + "&Long=" + event.coords.longitude;
}
// If something has gone wrong with the geolocation request
function onGeoError(event)
{
alert("Error code " + event.code + ". " + event.message);
}
function redirect()
{
window.location = redirectUrl;
}
setTimeout(redirect,15000);
</script>
</head>
<body onload="getLocationConstant()">
<br><br>
<a href="" id="location">URL?</a>
于 2012-07-28T14:35:01.403 回答