<legend id='gRuPU'><style id='gRuPU'><dir id='gRuPU'><q id='gRuPU'></q></dir></style></legend>

      <tfoot id='gRuPU'></tfoot>

      • <bdo id='gRuPU'></bdo><ul id='gRuPU'></ul>
      1. <i id='gRuPU'><tr id='gRuPU'><dt id='gRuPU'><q id='gRuPU'><span id='gRuPU'><b id='gRuPU'><form id='gRuPU'><ins id='gRuPU'></ins><ul id='gRuPU'></ul><sub id='gRuPU'></sub></form><legend id='gRuPU'></legend><bdo id='gRuPU'><pre id='gRuPU'><center id='gRuPU'></center></pre></bdo></b><th id='gRuPU'></th></span></q></dt></tr></i><div id='gRuPU'><tfoot id='gRuPU'></tfoot><dl id='gRuPU'><fieldset id='gRuPU'></fieldset></dl></div>

        <small id='gRuPU'></small><noframes id='gRuPU'>

        有没有办法检测用户是否已经授予使用 navigator

        时间:2023-09-06
      2. <tfoot id='UKNwg'></tfoot>

          <bdo id='UKNwg'></bdo><ul id='UKNwg'></ul>
          <legend id='UKNwg'><style id='UKNwg'><dir id='UKNwg'><q id='UKNwg'></q></dir></style></legend>
            <tbody id='UKNwg'></tbody>
            • <i id='UKNwg'><tr id='UKNwg'><dt id='UKNwg'><q id='UKNwg'><span id='UKNwg'><b id='UKNwg'><form id='UKNwg'><ins id='UKNwg'></ins><ul id='UKNwg'></ul><sub id='UKNwg'></sub></form><legend id='UKNwg'></legend><bdo id='UKNwg'><pre id='UKNwg'><center id='UKNwg'></center></pre></bdo></b><th id='UKNwg'></th></span></q></dt></tr></i><div id='UKNwg'><tfoot id='UKNwg'></tfoot><dl id='UKNwg'><fieldset id='UKNwg'></fieldset></dl></div>
                1. <small id='UKNwg'></small><noframes id='UKNwg'>

                2. 本文介绍了有没有办法检测用户是否已经授予使用 navigator.geolocation 的权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  除了第一次设置cookie之外,有没有办法检测用户是否已经允许navigator.geolocation返回浏览器的纬度/经度?

                  Apart from setting a cookie the first time round, is there a way of detecting whether a user has already given permission for navigator.geolocation to return the lat/long of the browser?

                  如果有,它是什么?它在所有浏览器中都相同还是在所有浏览器中不同?

                  If there is, what is it and is it the same across all browsers or different across all browsers?

                  此主题已在其他地方部分回答

                  根据 GeoLocation API – Chrome/Safari – 权限管理和视觉差异,Chrome 请求可撤销的一次性权限.我还没有读完这篇文章,但似乎权限存储并不是纯 Chrome 要做的事情.

                  According to GeoLocation API – Chrome / Safari – Permission management and Visual Differences, Chrome asks for a revokable one-time permission. I haven't finished reading the article, but it would seem that storage of permissions is not a purely-Chrome thing to do.

                  推荐答案

                  如何使用localStorage 应该被所有html5浏览器支持(支持geoLocation)

                  What about using localStorage which should be supported by all html5 browsers (that support geoLocation)

                  if (navigator.geolocation) {
                      navigator.geolocation.getCurrentPosition(successFunction, errorFunction);
                  } 
                  //Get latitude and longitude;
                  function successFunction(position) {
                      var lat = position.coords.latitude;
                      var long = position.coords.longitude;
                  
                      localStorage['authorizedGeoLocation'] = 1;
                  }
                  
                  function errorFunction(){
                      localStorage['authorizedGeoLocation'] = 0;
                  }
                  
                  function checkauthorizedGeoLocation(){ // you can use this function to know if geoLocation was previously allowed
                      if(typeof localStorage['authorizedGeoLocation'] == "undefined" || localStorage['authorizedGeoLocation'] == "0" ) 
                          return false;
                      else 
                          return true;
                  }
                  

                  然后您使用以下功能进行检查:

                  And then you check using the below function :

                  alert(checkauthorizedGeoLocation());
                  

                  这是 jsfiddle 如果您需要检查

                  这篇关于有没有办法检测用户是否已经授予使用 navigator.geolocation 的权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:等到某个条件成立? 下一篇:在新的 chrome (44.0.2403.157) 中,地理位置不起作用

                  相关文章

                  最新文章

                  1. <i id='F21sR'><tr id='F21sR'><dt id='F21sR'><q id='F21sR'><span id='F21sR'><b id='F21sR'><form id='F21sR'><ins id='F21sR'></ins><ul id='F21sR'></ul><sub id='F21sR'></sub></form><legend id='F21sR'></legend><bdo id='F21sR'><pre id='F21sR'><center id='F21sR'></center></pre></bdo></b><th id='F21sR'></th></span></q></dt></tr></i><div id='F21sR'><tfoot id='F21sR'></tfoot><dl id='F21sR'><fieldset id='F21sR'></fieldset></dl></div>

                      <bdo id='F21sR'></bdo><ul id='F21sR'></ul>

                    <small id='F21sR'></small><noframes id='F21sR'>

                      <tfoot id='F21sR'></tfoot>
                    1. <legend id='F21sR'><style id='F21sR'><dir id='F21sR'><q id='F21sR'></q></dir></style></legend>