if(navigator.geolocation) { navigator.geolocation.getCurrentPosition( function (position) { var longitude = position.coords.longitude; var latitude = position.coords.latitude; document.write(longitude+","+longitude) console.log(longitude) console.log(latitude) }, function (e) { var msg = e.code; var dd = e.message; document.write(msg+","+dd) console.log(msg) console.log(dd) } ) }