Elias Rub Elias Rub - 8 months ago 14
Javascript Question

browser feature detection error using (navigator.geoloction)

I have written a script to check if my browser has features. The following script is producing an error:


<title id="title"> code Issues </title>

//=================== 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


function geoError(errorObj)

if(typeof navigator.geolocation != "undefined")
console.log("inside geolocation");
navigator.geolocation.getCurrentPosition(geoSuccess, geoError);
alert("thos page uses Geolocation and your browser doesn't support it");

//=================== End of testing the feature detection method by using geolocation =======================//


<h1>List Publishers Ltd.</h1>
<div class="book">
<p>A book by J. Daniel Bedford</p>
<a href="#">Read now.</a>


If I run this I get an error that

I tried to debug the script and i can see it is not able to detect the function

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.