【问题标题】:HTML 5 Geolocation not working on chrome [duplicate]HTML 5 Geolocation 不适用于 chrome [重复]
【发布时间】:2018-01-13 19:18:00
【问题描述】:

我正在尝试使用此代码(如下),它在 Microsoft Edge 上运行良好,但在 chrome 上却不行,如何让它在 chrome 上运行?

$(document).ready(function() {

    $("button").click(function() {

        if (navigator.geolocation) {
            navigator.geolocation.getCurrentPosition(showPosition);
        }

        function showPosition(position) {
            $("p").append("Latitude: " + position.coords.latitude +
                "<br>Longitude: " + position.coords.longitude);
        }

    });

});

在 chrome 中,它甚至会提示允许该位置,但它不显示坐标。

谢谢

【问题讨论】:

标签: javascript html google-chrome geolocation weather-api


【解决方案1】:

由于安全原因,它们在 HTTP 中停止。它仅在 HTTPS 中工作

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-22
    • 2013-01-26
    • 2017-09-08
    • 2012-02-25
    • 1970-01-01
    相关资源
    最近更新 更多