My javascript code not fetching longitude and latitude from mobile chrome browser.
the below-given code is working for laptop or desktop browser but not mobile
<script>
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
}
function showPosition(position) {
alert(position.coords.latitude);
alert(position.coords.longitude);
document.getElementById("input1").value = position.coords.latitude;
document.getElementById("input2").value = position.coords.longitude;
}
</script>
display or get longitude and latitude on the website browser.