【发布时间】: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 中,它甚至会提示允许该位置,但它不显示坐标。
谢谢
【问题讨论】:
-
除了重复的问题,还请阅读developers.google.com/web/updates/2016/04/…
标签: javascript html google-chrome geolocation weather-api