我不知道我該怎麼完成從我的JavaScript定位代碼中href。 我有以下功能,它回饋我的經度和緯度。
function(obj){
if(navigator.geolocation){
navigator.geolocation.getCurrentPosition(userPosition,errorPosition);
}else {
alert('Geolocation is not available');
}
function userPosition(position){
obj.setAttribute('href', 'http://maps.google.com/maps? daddr=~ITEM.STREET~,+~ITEM.CITY~&saddr=' + position.coords.latitude + ',' position.coords.longitude);
}
function errorPosition(error){
switch(error.code){
case eror.PERMISSION_DENIED:
alert('permission denied');
break;
}
}
}
在這裏我得到我的當前位置他的經緯度作爲警報。 但我想要做的是以下。目前我有這個。
<a class=localization href="#" onclick="geo(this)">
<img src="images/localizationIcon.png" width=35 height=45 />
</a>
我想,當我點擊圖像。我的href中填充了經度和緯度。
有人可以幫我嗎?
親切的問候。
燕姿
是那些值會動態改變,而不會擊中服務器? – Mathletics 2012-04-24 13:12:44
不,它們不是 – Steaphann 2012-04-24 13:13:56