Code not working on server want to find geo-location and store into database
无法在服务器上运行的代码想查找地理位置并将其在w3school code.的本地主机上正常运行的数据库存储到数据库中
<!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) {
window.location = "position/?latitude="+position.coords.latitude+"&longitude="+position.coords.longitude;
}
</script>
</body>
</html>
答案 0 :(得分:0)
服务器上没有地理位置库。 navigator.geolocation
仅存在于浏览器中。