diff options
author | Dave Arter <davea@mysociety.org> | 2017-11-24 10:22:15 +0000 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2017-11-24 13:57:42 +0000 |
commit | d92f7d8f839623a0b11282073f377009d4f89220 (patch) | |
tree | 2bb00d2d9ef76a5027efd1b524403ba291ffa0ba /web/js | |
parent | 5777b0be63e1200880671aaf7128ca7e0ebb18f9 (diff) |
Hide geolocation link if not on HTTPS
Modern browsers disable geolocation on non-HTTPS pages, but
sadly still report it as available with the `navigator.geolocation`
object. This commit adds a check for HTTPS and hides the link
if it won’t work.
Diffstat (limited to 'web/js')
-rw-r--r-- | web/js/geolocation.js | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/web/js/geolocation.js b/web/js/geolocation.js index 5ff9fe9dc..3c2cf04df 100644 --- a/web/js/geolocation.js +++ b/web/js/geolocation.js @@ -29,7 +29,8 @@ fixmystreet.geolocate = function(element, success_callback) { (function(){ var link = document.getElementById('geolocate_link'); if (!link) { return; } - if ('geolocation' in navigator) { + var https = window.location.protocol.toLowerCase() === 'https:'; + if ('geolocation' in navigator && https) { fixmystreet.geolocate(link, function(pos) { var latitude = pos.coords.latitude.toFixed(6); var longitude = pos.coords.longitude.toFixed(6); |