Elias Rub Elias Rub - 2 years ago 76
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.

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download