Firefox 如何在网站中添加位置感知浏览?

Firefox 如何在网站中添加位置感知浏览?,firefox,geolocation,Firefox,Geolocation,如果我在firefox中打开网站,会弹出提示,要求我分享我的位置。这里是关于它的链接 如何将其添加到我的网站中?我猜锐步网站正在使用HTML5地理定位API 尝试下面的代码,它会重新创建行为。代码直接取自本页 var options = { enableHighAccuracy: true, timeout: 5000, maximumAge: 0 }; function success(pos) { var crd = pos.coord

如果我在firefox中打开网站,会弹出提示,要求我分享我的位置。这里是关于它的链接
如何将其添加到我的网站中?

我猜锐步网站正在使用HTML5地理定位API

尝试下面的代码,它会重新创建行为。代码直接取自本页

  var options = {
     enableHighAccuracy: true,
     timeout: 5000,
     maximumAge: 0
  };

  function success(pos) {
     var crd = pos.coords;

     console.log('Your current position is:');
     console.log('Latitude : ' + crd.latitude);
     console.log('Longitude: ' + crd.longitude);
     console.log('More or less ' + crd.accuracy + ' meters.');
  };

 function error(err) {
     console.warn('ERROR(' + err.code + '): ' + err.message);
 };

 navigator.geolocation.getCurrentPosition(success, error, options);