-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlocation.html
More file actions
26 lines (24 loc) · 773 Bytes
/
Copy pathlocation.html
File metadata and controls
26 lines (24 loc) · 773 Bytes
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
<html>
<head>
<script>
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition, showError);
} else {
document.getElementById("location").innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position) {
document.getElementById("location").innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
}
function showError(error) {
document.getElementById("location").innerHTML = "Error: " + JSON.stringify(error.code);
}
</script>
</head>
<body onload="getLocation()">
This is a small webpage that just tells you what your browser is telling me about where you are:
<div id="location"><i>loading...</i></div>
</body>
</html>