16

The script below works fine in FireFox and Chrome, but in Internet Explorer 11, it always fails (with POSITION_UNAVAILABLE).

I have set the browser to allow requests for position, and I agree to the prompt the browser presents me when requesting permission.

I'm almost certain that this worked fine a few months ago when I was last experimenting with it. What could I be missing as far as IE's settings?

<script type="text/javascript">
    $(document).ready(function () {
        if (Modernizr.geolocation)
        {
            navigator.geolocation.getCurrentPosition(positionSuccess, positionError, { enableHighAccuracy: true, maximumAge: 60000, timeout: 10000 })
        }
        else
        {
            $("#GeoError").html("Unable to retrieve current position.")
        }
    });

    function positionSuccess(position)
    {
        $("#Latitude").val(position.coords.latitude);
        $("#Longitude").val(position.coords.longitude);
    }

    function positionError(error)
    {
        var message = "";

        // Check for known errors
        switch (error.code) {
            case error.PERMISSION_DENIED:
                message = "This website does not have your permission to use the Geolocation API";
                break;
            case error.POSITION_UNAVAILABLE:
                message = "Your current position could not be determined.";
                break;
            case error.PERMISSION_DENIED_TIMEOUT:
                message = "Your current position could not be determined within the specified timeout period.";
                break;
        }

        // If it's an unknown error, build a message that includes 
        // information that helps identify the situation, so that 
        // the error handler can be updated.
        if (message == "") {
            var strErrorCode = error.code.toString();
            message = "Your position could not be determined due to " +
                      "an unknown error (Code: " + strErrorCode + ").";
        }

        $("#GeoError").html(message)
    }
</script>

Also, I get the same failure in IE11 when I try http://html5demos.com/geo, where both FireFox and Chrome work fine.

9
  • can you please show your script references? Feb 18, 2015 at 18:37
  • Not sure what you mean by "script references". I do reference a local copy of modernizr-2.8.3.js at the top of the page, and also local copies of jquery-2.1.3.js, bootstrap.js, and respond.js just before the script shown above. The problem I'm experiencing isn't limited to my code though. Feb 18, 2015 at 19:13
  • 2
    did you ever figure this out? I have the same problem and I can't find a solution
    – wintersylf
    Mar 22, 2015 at 2:12
  • 2
    I have the same issue with IE11 - does anyone know the solution Mar 23, 2015 at 16:52
  • 1
    If you have this problem, and this question has not found an answer, please up vote it. Nov 9, 2016 at 9:58

4 Answers 4

3

Does you enable the Location Service?

I have had the same issue, it worked after I enabled the Location Service in my windows 2016.

This page shows how to enable the Location Service in windows 10.

1

I have had the same issue in IE11 only. I had to set enableHighAccuracy to false to get it to work. Once I did that IE worked as expected.

1
  • 1
    I set enableHighAccuracy to false, but it did not work. My IE version is 11.1715.14393.0 .
    – cocoa
    Jan 5, 2018 at 5:41
0

In Internet Options, click on the Privacy tab. Uncheck the Never allow websites to request your physical location box, hit on OK.

After making these changes, the http://html5demos.com/geo now worked for me. Initially it didn't.

2
  • 3
    "Never allow websites to request your physical location" was already unchecked. As mentioned in the original question, the browser is already set to allow location requests, and I am asked for my permission, but it fails regardless. Feb 18, 2015 at 20:33
  • Tried all of these solutions. No luck.
    – zero_cool
    Feb 21, 2018 at 23:41
-2

aha, just discovered something. Chrome apparently uses the WIFI access points to help finding the location.

IE11 (and edge) just falls back to the default location in your windows settings, if there is no immediate GPS signal.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.