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 49 50 51 52 53 54 55 56 57 58
| <!DOCTYPE html>
<html lang="fr"> <!-- ABaseHTML.html -->
<head>
<meta http-equiv="content-type" content="text/html"; charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Minimum pour page HTML</title>
<style>
</style>
<script>
'use strict'; // force la déclaration des variables
//********************************************************************************
//--------------------------------------------------------------------------------
</script>
</head>
<body> <!-- ........................................................................................................... -->
<script> // ............................................................................................................. //
getLocation();
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition, showError);
} else {
alert("Geolocation non supprotée par votre navigateur.");
}
} //---------------------------------------------------------
function showError(error) {
switch(error.code){
case error.PERMISSION_DENIED:
alert("Utilisateur a rejeté la demande de géolocalisation.");
break;
case error.POSITION_UNAVAILABLE:
alert("Informations sur la localisation ne sont pas disponibles.");
break;
case error.TIMEOUT:
alert("La demande pour obtenir lemplacement de lutilisateur a expiré.");
break;
case error.UNKNOWN_ERROR:
alert("Une erreur inconnue sest produite.");
break;
}
}
function showPosition(position){
alert("vous avez autoriser la géolocalisation.");
alert ("Latitude " + position.coords.latitude + " Longitude " + position.coords.longitude);
} //---------------------------------------------------------
</script> <!-- ......................................................................................................... -->
</body> <!-- ........................................................................................................... -->
</html> |
Partager