I am creating a website which will only allow a user on it if your location is unblocked, I was trying to make if location doesn't exist, then don't allow the user
I tried using
if (typeof(showPosition)=="undefined") {
document.getElementById("x").innerHTML = "object is null ";
}
and
if (!showPosition){
document.getElementById("x").innerHTML = "object is null ";
}
and
if (showPosition == "null"){
document.getElementById("x").innerHTML = "object is null ";
}
But none of the above methods worked.
Here are my two functions
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition, showError);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position) {
x.innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;