On page load get latitude and logitude in pure javascript.
There are other methods also to find the lat long on page load. The below
example showing how to show latitude and longitude on page load in pure javascript

<html lang="en">
<title>On page load get latitude and logitude in pure javascript</title>
<script type="text/javascript">
navigator.geolocation.getCurrentPosition(afterSuccess, afterError);    function afterSuccess(position) {       lat=position.coords.latitude ; lng=position.coords.longitude ;  document.getElementById("latlong").innerHTML='Your Latitude = '+lat+' & Longitude = '+lng; }
function afterError(error)    {
document.getElementById("latlong").innerHTML="Please enable gps location";
<div id="latlong"></div>

Leave comment

Your email address will not be published. Required fields are marked with *.