2 years ago
#70536
anyoneknow
Get geolocation and save it to text file
Hello I have this code and I want to get latitude and longitude of the guest and save them to a text file after click the button
this the code what I used thank you
<!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,errorCallback, { timeout:5000 });
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position) {
var latlong = x.innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
//document.location='http://192.168.0.100:4321/'+latlong;
}
function errorCallback(error) {
x.innerHTML = "failed";
}
</script>
</body>
</html>
javascript
php
html
geolocation
0 Answers
Your Answer