布局代码如下

<p >试一下</button>

js代码如下

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;
}

相关文章:

  • 2022-12-23
  • 2021-12-20
  • 2022-12-23
  • 2021-11-17
  • 2022-02-28
  • 2021-08-16
  • 2021-12-10
  • 2021-12-10
猜你喜欢
  • 2021-09-23
  • 2021-10-21
  • 2021-09-27
  • 2021-12-19
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案