Javascript mobile safari-navigator.geolocation.getCurrentPosition“;扼住;应用程序(如果已添加书签)(全屏)

Javascript mobile safari-navigator.geolocation.getCurrentPosition“;扼住;应用程序(如果已添加书签)(全屏),javascript,html,geolocation,Javascript,Html,Geolocation,我在使用html5的地理定位API开发的web应用程序中发现了这种奇怪的行为。只有将网站添加到书签,然后在iPad上使用 在标题中 我正在使用的代码: function getLocation() { if (navigator.geolocation) { alert("No problem up to here"); navigator.geolocation.getCurrentPosition(showPosition, noLocation, { timeout:

我在使用html5的地理定位API开发的web应用程序中发现了这种奇怪的行为。只有将网站添加到书签,然后在iPad上使用
在标题中

我正在使用的代码:

function getLocation() {
  if (navigator.geolocation) {
    alert("No problem up to here");
    navigator.geolocation.getCurrentPosition(showPosition, noLocation, { timeout:   10000 });
}
else {
  alert("Geolocation is not supported by this browser.");
}
}

function showPosition(position) {
  alert("position: " + position.coords.latitude + ', ' + position.coords.longitude);
}

function noLocation(error) {
  alert("error.code:" + error.code);
}    
然后我从另一个函数调用getLocation():

    timer = window.setInterval(function () { getLocation() }, 10000);
(是的,我已经声明了计时器)

我使用“阻塞”一词是因为我可以每10秒看到一次“到此为止没有问题”警报,“
位置:
”警报只出现一次,然后“
位置:
”或“
错误。代码:
”警报都不会出现


知道为什么会发生这种情况吗?

当弹出请求权限的窗口出现,用户单击chrome或firefox中的关闭窗口(x),或safari中的“Not Now”按钮,或者根本不回答并将其保留时,就会发生这种情况。您是否单击了“不是现在”,或者可能是由于某种原因,您没有看到对您位置的请求。据我记忆所及,我单击了“确定”。现在它甚至没有显示提示,但我在右上角看到一个小箭头,表示它不知何故记住了我的选择并使用了地理位置。尝试简化警报,只需使用类似于
alert('here')的文字。可能位置对象没有按您期望的方式出现。已经尝试过了。实际上这是第一次执行。然后什么也不做,就像我在原始帖子中描述的那样。因此,我只看到“位置”警报一次,但每10秒“到这里没问题”。