当我按下"ok"键时如何调用函数;在navigator.geolocation.getCurrentP

how to call a function when I press "ok" on navigator.geolocation.getCurrentPosition()

本文关键字:quot 调用 函数 geolocation getCurrentP navigator ok 何调用      更新时间:2023-09-26

我有这个函数:

navigator.geolocation.getCurrentPosition(foundLocation, noLocation);

从手机获取当前GPS位置。现在,当我按下"确认"在手机上,在做检索位置的请求之前,我想调用一个函数(所以,不是在foundLocation()中,位置数据已经准备好了)。

我该怎么做?

<button id="btnConfirm">Confirm</button>
document.getElementById("btnConfirm").onclick = function()
{
  call_your_function();
  navigator.geolocation.getCurrentPosition(foundLocation, noLocation);
}
相关文章: