This is most recent
Anyone know why this wont redirect?
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;
}
function redirect()
{
window.location.href = redirectUrl;
}
setTimeout(redirect,15000);
I’m stuck on brain fart mode and can’t seem to write a javascript variable to an A anchor href. Ideas? I’m sure I’m missing something simple…
So Javascript is pulling GPS below – works fine…
I need it to populate the Lat and Long into an anchor href… Without an “onclick” – needs to populate automatically…
So:
<a href="page.htm?Lat=javascript(latitude)&Long=javascript(longitude)">GPS Location</a>
javascript(latitude) - is variable I need to pull from below Javascript
javascript(longitude) - is variable I need to pull from below Javascript
<script type="text/javascript">
function getLocationConstant()
{
if(navigator.geolocation)
{
navigator.geolocation.watchPosition(onGeoSuccess,onGeoError);
} 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;
}
// If something has gone wrong with the geolocation request
function onGeoError(event)
{
alert("Error code " + event.code + ". " + event.message);
}
</script>
1 Answer