在我添加此代码之前,Safari iOS iOS 5上的一切正常工作:
var watchID = navigator.geolocation.watchPosition(updatePos,locationError,{maximumAge: 10000, frequency: 60000, enableHighAccuracy: true, timeout: 1000});
function updatePos(position) {
if (position.coords.accuracy < accuracyThreshold) {
$.post(websiteRoot + '/ReportDeviceLocation?rand=' + (Math.random() * Math.random()) + '&longitude=' + position.coords.longitude + '&latitude=' +position.coords.latitude);
} else {
console.debug("Location data is not accurate enough. Location not updated.");
}
}
Run Code Online (Sandbox Code Playgroud)然后网页工作了大约4分钟,我得到这个错误:
JavaScript执行超过了超时.
然后没有JavaScript会加载.我插入到my.js文件中的调试消息都不会打印出来.只有上面的错误.
即使在我离开生成此错误的页面并在同一域下打开其他网页后,错误仍然存在.
我用过try和catch,我使用了setTimeout函数,但是既没有给我错误的来源也没有解决问题.
我不知道问题是什么.它一整天都在燃烧我,并会在周末燃烧我.