【发布时间】:2012-05-05 02:57:00
【问题描述】:
编辑
我想知道如何使用 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中。
有人可以帮帮我吗?
亲切的问候。
史蒂夫
【问题讨论】:
-
这些值会在不影响服务器的情况下动态变化吗?
标签: javascript html css anchor href