是否可以在没有浏览器提示的情况下获取用户的地理位置?
Here's the code sample from W3
<script>
var 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>
是否有类似preventPrompt()
的功能?