Rajeev_ranjan Rajeev_ranjan - 3 years ago 260
Javascript Question

Why geolocation is not supporting in my any browser?

Why geolocation is not supporting in my any browser ?
I am new in the world of javascript.

Here is my Code which I am running at node js server.

<!DOCTYPE html>
<button onclick="getLocation()">Get coords</button>
<h1 id="coords"></h1>
var x=document.getElementById('coords');
function getLocation(){
if (navigator.Geolocation) {
x.innerHTML="Geolocation is not supported";
function showPosition(position){

This is Output

Answer Source

You have to pay attention to the capitalization: Change navigator.Geolocation) to navigator.geolocation.

Documentation of the geolocation API on MDN: https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/Using_geolocation

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