这是最新的写Javascript变量到<a href> - 不onclick
任何人都知道为什么这不会重定向?
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);
我卡在脑屁模式,似乎无法写入一个JavaScript变量的锚点href。想法?我敢肯定,我失去了一些东西简单...
下方,以便JavaScript是拉动全球定位系统 - 正常工作...
我需要它来填充纬度和长成一个锚的href ......没有一个“onclick”事件 - 需要自动填充......
所以:
<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>
得到它通过消除VAR想通重定向 – 2012-07-28 15:48:18