geolocation not working on safari browser,but its working fine on Chrome,IE,Mozila


I am using HTML5 geolocation which is not working on safari browser,but its working fine on Chrome,IE,Mozila,here is my current javascript code

<script>
$(function () {

$("#btnLocateMe").click(function () {
if ($("#txtLat").val() == "" || $("#txtLng").val() == "")
{
show_user_location();
}
else
{
$("#btnRedirect").trigger("click");
}
});
});


function show_user_location() {

navigator.geolocation.getCurrentPosition(display_user_location, error_response);
}
function display_user_location(user_position) {
var lat = user_position.coords.latitude;
var lon = user_position.coords.longitude;
$("#txtLat").val(lat);
$("#txtLng").val(lon);
$("#btnRedirect").trigger("click");

}

function error_response() {
alert("Location is required to find restaurants near by you.");
}
</script>

How do I make it work on safari also?


Asked by:- RameshwarLate
0
: 322 At:- 2/5/2018 8:32:18 AM
html5 geolocation javascript






1 Answers
profileImage Answered by:- Sam

You didn't mention Safari browser version in which code isn't working, and your website link to verify issue, you can try this 

Open System Preferences / Security and select the General tab.

Click the gold padlock icon bottom left in the pane to make any necessary changes. You will be prompted for your admin password.

If necessary, make sure: Disable Location Services is not selected. Click: Reset Warnings.Relaunch Safari. See if that made a difference.

also, please check these links which may help

  1. https://discussions.apple.com/thread/2467998
  2. https://stackoverflow.com/questions/3686630/geolocation-not-workin-on-safari-5-x-on-windows-7-xp
  3. https://stackoverflow.com/questions/32948143/html5-geolocation-not-working-on-safari-browser

According to https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/getCurrentPosition  geolocation is supported in Safari 5.0 and above

1
At:- 2/5/2018 10:40:23 AM Updated at:- 2/5/2018 10:44:30 AM





Login/Register to answer
Or
Register directly by posting answer/details

Full Name *

Email *




By posting your answer you agree on privacy policy & terms of use