Need help understanding this HTML5 Code.
Hey folks, 

Hope everyone's doing well.

Happened to go-through some interview articles.

Just needed an understanding, like the below code requests users' permission for accessing their coordinates via geolocation API. How many other methods there exist in Geolocation Object and what would their usage be in real-time.

<!DOCTYPE html>
<p>Click "try it" button to get your coordinates.</p>
<button onclick="getLocation()">Try It</button>
<p id="demo"></p>
var x = document.getElementById("demo");

function getLocation() {
if (navigator.geolocation) {
} else {
x.innerHTML = "Geolocation functionality is not supported by this browser.";

function showPosition(position) {
x.innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;


Forum Jump:

Users browsing this thread: 1 Guest(s)