Files
BPIT-ATTENDANCE/yash/html/i.php.html
2024-06-03 16:43:53 +03:00

50 lines
808 B
HTML

<?php
$dochtml = new DOMDocument();
$dochtml->loadHTMLFile("index.php.html");
$div = $dochtml->getElementById('div2')->nodeValue;
?>
<!DOCTYPE html>
<html>
<body>
<div>
<h1>HTML Geolocation</h1>
<p>Click the button to get your coordinates.</p>
<button onclick="getLocation()">Try It</button>
<p id="demo"></p>
<script>
const x = document.getElementById("demo");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position) {
x.innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
}
</script>
</div>
</body>
</html>