【发布时间】:2019-10-12 20:14:24
【问题描述】:
我的 javascript 代码没有从移动 chrome 浏览器获取经度和纬度。
下面给出的代码适用于笔记本电脑或台式机浏览器,但不适用于移动设备
<script>
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
}
function showPosition(position) {
alert(position.coords.latitude);
alert(position.coords.longitude);
document.getElementById("input1").value = position.coords.latitude;
document.getElementById("input2").value = position.coords.longitude;
}
</script>
在网站浏览器上显示或获取经纬度。
【问题讨论】:
-
这个link 可以帮助你。
-
谢谢,但我已经在使用 chrome v 74.0.3 移动版
-
也许你也应该发布你的html
-
@AravindhNagarajan 谢谢你,但即使这也不适用于桌面浏览器。
标签: javascript php html mobile location