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;
}
How can I execute the function accept in updatePosition ?
Put ()
after the name.
Why can denyexecute itself
It can't. You are passing deny
as an argument to navigator.geolocation.getCurrentPosition
. The code in navigator.geolocation.getCurrentPosition
calls it.