0
4

2 に答える 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 は私を正しい方向へと導いてくれました - あまりにも引っ張ることができず、本体にオンロードを追加する必要がありました。

今、そのURLにリダイレクトしようとしていますが、javascriptリダイレクトではうまくいきません...

Thxゾルタン

  <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 に答える