Jump to content

Geolocation wont work. What did i do wrong?


Joelthezombie15

Recommended Posts

So im using notepad++ and im trying to get geolocation to work but it wont.

 

This is what i have so far.

 

<p id="demo">Click the button to get your coordinates:</p>

<button onclick="getLocation()">Try It</button>
<script>
var x=document.getElementById("demo");
function getLocation()
{
if (navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(showPosition);
}
else{x.innerHTML="Geolocation is not supported by this browser.";}
}
function showPosition(position)
{
x.innerHTML="Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
}
</script>

It should work. but it wont (Im using chrome) did i mess something up?

 

Link to comment
Share on other sites

  • 1 month later...

I am using chrome. why the geolocation wont showing getLocation i checked on my advance setting there is no necessarily checkbox "Send a "Do Not Track" request with your browsing traffic"

 

I am not sure what excalty the file will go through from the document.getElementById("demo").

 

I checked at http://www.w3schools.com/html/html5_geolocation.asp it does not help me

 

please help me what did i wrong anyone who have experienced this problem before

 

thanks!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...