HTML5 Geolocation does not request permission and does not work on Samsung S3

Using the standard HTML5 geolocation code, I can access geolocation on desktop browsers (Chrome, Firefox), but not on my Samsung Galaxy S3 (default browser, Chrome). Nothing happens in the default browser. In Chrome, a yellow permission form appears at the bottom, and then pops up too quickly to click anything. I checked that the location is enabled in the settings. I am considering looking for a PHP solution as a backup for cases where the JavaScript / HTML5 solution breaks down like this, but would prefer the JavaScript solution to be more reliable.

Has anyone come across this and fixed it? Any ideas?

For reference, the “standard” HTML5 anchor code that I am referring to is (example code from basic geolocation in HTML5 ):

<script type="text/javascript">
      if( navigator.geolocation )
      {
           // Call getCurrentPosition with success and failure callbacks
           navigator.geolocation.getCurrentPosition( success, fail );
      }
      else
      {
           alert("Sorry, your browser does not support geolocation services.");
      }

      function success(position)
      {
            // GeoPosition Object
           alert("Your coordinates are " + position.latitude + ", " + position.longitude);
      }
      function fail()
      {
           // Could not obtain location
      }
 </script>
+5
source share
1 answer

Odd. I did 3 things and now it works in both phone browsers (default and chrome)

  • I put the main code in a function called in <body onload="">
  • I restarted my phone
  • I turned off power saving mode

I suspect the reboot did everything possible, as I saw the resolution pop up on the screen in chrome.

0
source

All Articles