Geolocation does not work [Spoiler]

Hi! Im trying to get the latitude and the longitude from the navigator with the code in the challenge but it does not work:

 if (navigator.geolocation) {
  navigator.geolocation.getCurrentPosition(function(position) {
    $("#data").html("latitude: " + position.coords.latitude + "<br>longitude: " + position.coords.longitude);
  });
}

That exact code works fine for me in the challenge.

Can you post all of your code from the challenge? I suspect you haven’t put it between the script tags properly.

    <script>
      // Only change code below this line.
      
      if (navigator.geolocation) {
      navigator.geolocation.getCurrentPosition(function(position) {
        $("#data").html("latitude: " + position.coords.latitude + "<br>longitude: " + position.coords.longitude);
      });
    }
  
  // Only change code above this line.
</script>
<div id = "data">
  <h4>You are here:</h4>
  
</div>

That still passes the tests for me.

Try clearing the browser cache and resubmitting that solution.

I think that is a problem in Opera. The code works fine in Chrome. :disappointed:

According to http://caniuse.com/#search=geolocation Opera allows navigator.geolocation from secure (https) servers. Free Code Camp is https, so I can’t imagine what the problem would be.

For opera, you can verify your setting here:

Settings > Preferences > Advanced > Network

Is “Allow websites to request my physical location” checked?

yes, the option is checked!

Maybe check the geolocation exceptions to ensure you didn’t accidentally block FCC from using the geolocation:

Checked that too:cry::cry::cry::cry::cry::cry::cry::cry::cry::cry::cry::cry::cry:

Does your address bar have the blue geolocation icon and the green padlock?

Also, what version of Opera are you using?

The blue icon appears.

41.0.2353.46 - Opera is actualized.

When you press Ctrl + Shift + Iand select console, does it report any errors?

Error shown:

Get https://www.google-analytics.com/analytics.js Failed to load resource: net::ERR_CONNECTION_REFUSED

Interesting…

With a completely clean install of Opera, I don’t get that error when I run the code.

Is it possible that you have some plug-ins installed that block Javascript? Like NoScript or something like that?

I had Adblock but i deactivated.

Sorry… the error was previous.:grin:

Haha! No worries.

You said before that you have the blue icon - do you have the green padlock icon as well?

yes! … the alert is shown for you in opera??