【问题标题】:Geolocation html5 working on web browser but not on iphone browserGeolocation html5 在网络浏览器上工作,但在 iPhone 浏览器上不工作
【发布时间】:2017-02-27 09:07:18
【问题描述】:

我使用下面的代码来获取纬度和经度,在网络浏览器 chrome、firefox 上我能够获取位置,但是当我在 IOS safari 和 firefox 上运行该站点时,我无法获取纬度和经度.

<!DOCTYPE html>
<html>
<body>

<p>Click the button to get your coordinates.</p>

<button onclick="getLocation()">Try It</button>

<p id="demo"></p>

<script>
var x = document.getElementById("demo");

function getLocation() {
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(showPosition);
    } else { 
        x.innerHTML = "Geolocation is not supported by this browser.";
    }
}

function showPosition(position) {
    x.innerHTML = "Latitude: " + position.coords.latitude + 
    "<br>Longitude: " + position.coords.longitude;
}
</script>

</body>
</html>

【问题讨论】:

    标签: ios html firefox geolocation


    【解决方案1】:

    打开浏览器应用的定位服务。

    -点击设置应用程序 -打听个人隐私 -点击定位服务 - 将开关切换到开启

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-10-24
    • 1970-01-01
    • 1970-01-01
    • 2016-01-27
    • 1970-01-01
    • 2019-08-26
    • 1970-01-01
    相关资源
    最近更新 更多