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]( fccss %20%20%2F%2F%20Only%20change%20code%20below%20this%20line. %20%20 %20%20if%20(navigator.geolocation)%20{ %20%20navigator.geolocation.getCurrentPosition(function(position)%20{ %20%20%20%20%24("%23data").html("latitude%3A%20"%20%2B%20position.coords.latitude%20%2B%20"<br>longitude%3A%20"%20%2B%20position.coords.longitude)%3B %20%20})%3B%0A%7D%0A%20%20%0A%20%20%2F%2F%20Only%20change%20code%20above%20this%20line.%0Afcces%0A%3Cdiv%20id%20%3D%20%22data%22%3E%0A%20%20%3Ch4%3EYou%20are%20here%3A%3C%2Fh4%3E%0A%20%20%0A%3C%2Fdiv%3E%0A).

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

      // 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.
<div id = "data">
  <h4>You are here:</h4>

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 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 Failed to load resource: net::ERR_CONNECTION_REFUSED


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??