Jump to content
Sign in to follow this  
joshmaxwell

getCurrentPosition not working in safari or IE11

Recommended Posts

The file at this url contains exactly the code below, and the domain is SSL https://staging13.dgstesting.com/new2.html

<!DOCTYPE html>
<html>
  <head>
    <script>  
        navigator.geolocation.getCurrentPosition(function(position){
                document.body.innerHTML = position.coords.latitude;
        }, function(error){
                document.body.innerHTML = error.message;
        });
    </script>
  </head>
  <body>
  </body>
</html>

The problem: On chrome, edge beta (so basically chrome) and chrome on android, this code will succeed and print your devices latitude to the page. On Safari, safari for ios, and IE11, this will fail with the message "This site does not have permission to use the Geolocation API."

I assume it's not referring to the user granting permission to access location data, but i checked this anyway. Doesn't appear to be the case because it's working in one browser but not another on the same device. In my example, it works in chrome but not ie11 on the same windows 10 computer. I also had a coworker confirm the same thing, it works in chrome but not safari on his mac.

That leaves me thinking it's a domain issue, but why would it work in one browser and not another? After tons of Googling the best answer I can find is that it is an SSL issue, but if you go to https://developers.google.com/maps/documentation/javascript/geolocation you can see that even google.com is facing the same issue. So I think that rules that out. you can even try it on w3schools own site https://www.w3schools.com/html/html5_geolocation.asp

Google of course has no input here because navigator is a product of html5

Share this post


Link to post
Share on other sites

You probably should check the security settings of each of your browsers. Whenever the website makes a request for the location, the browser asks the user for permission. If this is not happening it's likely that the browser has been configured to reject all location permission requests. Each browser has its own permission setting, it is not shared across browsers.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...