The HTML Geolocation API is used to locate a user's position.

how to get location web brower get notifcation allow to current location of user
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<titleHTML5 Geolocation API</title>
<script>
function getLocation() {
if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var positionInfo = "Your current position is (" + "Latitude: " + position.coords.latitude + ", " + "Longitude: " + position.coords.longitude + ")";
document.getElementById("result").innerHTML = positionInfo;
});
} else {
alert("Sorry, your browser does not support HTML5 geolocation.");
}
}
</script>
</head>
<body>
<div id="result">
<!--Position information will be inserted here-->
</div>
<button type="button" onclick="getLocation();">Show Position</button>
</body>
</html>

No comments

Note: only a member of this blog may post a comment.