fork download
  1.  
Success #stdin #stdout 0.03s 9576KB
stdin
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Location Tracker</title>
</head>
<body>
    <h1>Location Tracker</h1>
    <button id="getLocation">Get Location</button>
    <div id="location"></div>

    <script>
        document.getElementById('getLocation').addEventListener('click', () => {
            if (navigator.geolocation) {
                navigator.geolocation.getCurrentPosition(showPosition);
            } else {
                document.getElementById('location').innerText = "Geolocation is not supported by this browser.";
            }
        });

        function showPosition(position) {
            document.getElementById('location').innerText = `Latitude: ${position.coords.latitude}, Longitude: ${position.coords.longitude}`;
        }
    </script>
</body>
</html>
stdout
Standard output is empty