不工作我已经使用在Mozilla和Chrome浏览器下面的脚本。在Mozilla中,它询问我们是否要共享位置。但在铬它没有显示任何东西。地理位置铬
<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>
该网站公开托管。仍然没有工作。 –
根据我的答案,您是否正在运行HTTPS? – Sk93