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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
Post a Comment