I have written a script to check if my browser has features. The following script is producing an error:
<!DOCTYPE HTML>
<html>
<head>
<title id="title"> code Issues </title>
</head>
<body>
//=================== testing the feature detection method by using geolocation =======================//
function geosuccess(position)
{
var cords = position.cords;
var latitude = position.latitude;
var longitude = postion.longitude;
var message = "You're at " + latitude + ", " + longitude
alert(message);
}
function geoError(errorObj)
{
alert(errorObj.message);
}
if(typeof navigator.geolocation != "undefined")
{
console.log("inside geolocation");
navigator.geolocation.getCurrentPosition(geoSuccess, geoError);
}
else
{
alert("thos page uses Geolocation and your browser doesn't support it");
}
//=================== End of testing the feature detection method by using geolocation =======================//
</script>
<h1>List Publishers Ltd.</h1>
<div class="book">
<h2>Sprout.</h2>
<p>A book by J. Daniel Bedford</p>
<a href="#">Read now.</a>
</div>
</body>
</html>
If I run this I get an error that geosuccess
isundefined
.
I tried to debug the script and i can see it is not able to detect the function geoSuccess(position)
.
I hope I am not missing an object oriented concept and the error is something related to the browser maybe.
First, your code lacks an opening <script>
tag but I'll assume that's just a mistake.
Second, your code defines the function as geosuccess
but you pass geoSuccess
to getCurrentPosition
. Please check wheter the cases match in your code.