01.
<!DOCTYPE html>
02.
<html>
03.
<body>
04.
05.
<script>
06.
function
getLocation() {
07.
if
(navigator.geolocation) {
08.
navigator.geolocation.getCurrentPosition(redirectToPosition);
09.
}
else
{
10.
x.innerHTML =
"Geolocation is not supported by this browser."
;
11.
}
12.
}
13.
14.
function
redirectToPosition(position) {
15.
window.location=
'test.php?lat='
+position.coords.latitude+
'&long='
+position.coords.longitude;
16.
}
17.
18.
getLocation()
19.
20.
</script>
21.
22.
<?php
23.
echo
$lat
=(isset(
$_GET
[
'lat'
]))?
$_GET
[
'lat'
]:
''
;
24.
echo
$long
=(isset(
$_GET
[
'long'
]))?
$_GET
[
'long'
]:
''
;
25.
?>
26.
27.
</body>
28.
</html>