-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeoLocation.html
32 lines (32 loc) · 891 Bytes
/
geoLocation.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
32
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>GeoLocation Testing</title>
<style>
body {
font-family: "Lucida Console", Monaco, monospace
}
</style>
</head>
<body>
<h2>GeoLocation Testing</h2>
<div id='location'></div>
</body>
<script>
var div_location = document.getElementById("location");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
div_location.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position) {
div_location.innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
}
getLocation();
</script>
</html>