【发布时间】:2017-06-06 17:34:33
【问题描述】:
我有这个识别用户位置的基本功能:
function getLocation()
{
if (navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(showmyPosition, errorCallback);
}
else
{
alert("Geolocation is not supported by this browser.");
}
}
function showmyPosition(position)
{
document.location.href="/search?lat="+ position.coords.latitude +"&lng="+ position.coords.longitude +"";
}
function errorCallback(error) {
if (error.code === 1) {
alert("User denied geolocation");
}
}
在 Firefox、Chrome 和 Explorer 上运行良好,但在 Safary 上无法运行(在 iPhone 上也不行)。为什么?
【问题讨论】:
标签: javascript iphone html safari geolocation