Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form>
- <input type="text" id="lat" name="lat">
- <input type="text" id="lon" name="lon">
- </form>
- <script>
- function show_position(position) {
- document.getElementById('lat').value = position.coords.latitude;
- document.getElementById('lon').value = position.coords.longitude;
- }
- function get_geolocation(){
- if (navigator.geolocation) {
- navigator.geolocation.getCurrentPosition(show_position);
- }
- }
- document.addEventListener("DOMContentLoaded", function(event) {
- get_geolocation();
- });
- </script>
Add Comment
Please, Sign In to add comment