How can I execute the function accept
in updatePosition
? Why can deny
execute itself but not accept
?
accept = alert(123);
deny = alert(123);
function getLocation(accept,deny) {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (position) {
updatePosition(position, accept);
}, deny);
} else {
deny;
}
}
function updatePosition(position, accept) {
PositionLat = position.coords.latitude;
PositionLon = position.coords.longitude;
accept;
}
Put
()
after the name.It can't. You are passing
deny
as an argument tonavigator.geolocation.getCurrentPosition
. The code innavigator.geolocation.getCurrentPosition
calls it.