-
Notifications
You must be signed in to change notification settings - Fork 53
/
index.html
31 lines (28 loc) · 970 Bytes
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<button id="checkGeolocation">Check geolocation</button>
<div>
<span>Latitude:</span><span id="latitudeValue"></span>
</div>
<div>
<span>Longitude</span><span id="longitudeValue"></span>
</div>
<script>
var checkGeolocationBtn = document.getElementById('checkGeolocation');
checkGeolocationBtn.addEventListener('click', function () {
function success(position) {
var latitudeElement = document.getElementById('latitudeValue');
var longitudeElement = document.getElementById('longitudeValue');
latitudeElement.textContent = position.coords.latitude;
longitudeElement.textContent = position.coords.longitude;
}
navigator.geolocation.getCurrentPosition(success);
});
</script>
</body>
</html>