0

I was wondering if it is possible to use Javascript Geolocation to change a variable?

enter image description here

As in- if I am in California, then my Javascript geolocation code will return true. But if I am somewhere else it will return false.

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 + "<br>Longitude: " + position.coords.longitude; 
}

Is there any way to do this?

Scott Marcus
  • 64,069
  • 6
  • 49
  • 71
CodeShady
  • 46
  • 11

0 Answers0