JSFiddle - React, Tailwind, and code Playground
JavaScript
// if geo location add on is available
if (navigator.geolocation) {
// get location by using the built-in function of geo location
s.geolocation.getCurrentPosition(function(a) {
// you get the coordinates in the result parameter
var lat = "latitude: " + a.coords.latitude;
var lon = "longitude: " + a.coords.longitude;
// write the coordinates to document
document.write(lat);
document.write("<br>");
document.write(lon);
}, function(a) {
// aww, some error occured.
document.write("could not find your location!");
});
}
else {
// browser does not support geo location
document.write("Your browser does not support geo location, please try using another browser.");
}