我在使用html5的地理定位API开发的Web应用程序中发现了这种奇怪的行为。如果网站已加入书签,然后在iPad上以全屏模式运行,则只会出现此问题
<meta name="apple-mobile-web-app-capable" content="yes" />
在标题中。
我正在使用的代码:
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);
(是的,我已经宣布了计时器)
我使用了“choke”这个词,因为我每隔10秒钟就可以看到“此处没问题”提醒,“position:
”提醒一次,之后“position:
“或”error.code:
“警报正在显示。
为什么会发生这种情况?