HTML & JavaScript Geo Location test: Difference between revisions
		
		
		
		Jump to navigation
		Jump to search
		
 Created page with "[NOWIKI] <p>Click the button to get your coordinates.</p>  <button onclick="getLocation()">Try It</button>  <p id="demo"></p>  <script> var x = document.getElementById("demo");  function getLocation() {   if (navigator.geolocation) {     navigator.geolocation.getCurrentPosition(showPosition);   } else {      x.innerHTML = "Geolocation is not supported by this browser.";   } }  function showPosition(position) {   x.innerHTML = "Latitude: " + position.coords.latitude +..."  | 
			
(No difference) 
 | 
Revision as of 17:40, 31 July 2022
[NOWIKI]
Click the button to get your coordinates.
<button onclick="getLocation()">Try It</button>
<script> var x = document.getElementById("demo");
function getLocation() {
 if (navigator.geolocation) {
   navigator.geolocation.getCurrentPosition(showPosition);
 } else { 
   x.innerHTML = "Geolocation is not supported by this browser.";
 }
}
function showPosition(position) {
x.innerHTML = "Latitude: " + position.coords.latitude + "
Longitude: " + position.coords.longitude;
} </script> [/NOWIKI]