litesoft
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
<!DOCTYPE html>
<html>
<head>
<script>
var messageDiv = document.getElementById('message');
function initLocation ( )
{
// Try HTML5-spec geolocation: http://dev.w3.org/geo/api/spec-source.html
var geolocation = navigator.geolocation;
if (geolocation)
{
// Try Catch
try
{
// getCurrentPosition function as stated in the spec
navigator.geolocation.getCurrentPosition( successCallback, errorCallback );
}
catch (err)
{
messageDiv.innerHTML = 'Error';
}
}
else
{
messageDiv.innerHTML = 'Your browser is not capable of looking up your location.';
}
}
function successCallback ( location )
{
message.innerHTML="<p>Longitude: " + location.coords.longitude + "</p>";
message.innerHTML+="<p>Latitude: " + location.coords.latitude + "</p>";
message.innerHTML+="<p>Accuracy: " + location.coords.accuracy + "</p>";
}
function errorCallback ( )
{
messageDiv.innerHTML = 'There was an error looking up your position';
}
</script>
</head>
<body onload="initLocation()">
<div id="message">Looking Up Location</div>
</body>
</html>
|
Revision |
Author |
Commited |
Message |
61
|
GeorgeS
|
Thu 26 Aug, 2010 22:55:09 +0000 |
|