最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Chrome has blocked my geolocation tracking - Stack Overflow

programmeradmin2浏览0评论

I am developing a webpage using "geolocation" and for that I need to allow access and deny access many times a day just to see how it works with my code. Here is just a code example.

<script>
    if (navigator.geolocation) {
                navigator.geolocation.getCurrentPosition(showPosition);
/*        navigator.geolocation.getCurrentPosition(showPosition, showError);*/
    } else { 
        alert("Geolocation is not supported by this browser.")
    }
</script>

All of a sudden It always denies tracing my location and when I click the trace icon it says

"The following sites have been blocked from tracking your location on this page <my page name>" 

And below it says

"Settings will be cleared on next reload"

I've tried to reload the page, I've tried to restart Google Chrome, I've entered in the location settings but the block list is empty so I can't find my page there either.

So what can I do? I can't continue to develop my page as long as my page is permanently blocked.

I am developing a webpage using "geolocation" and for that I need to allow access and deny access many times a day just to see how it works with my code. Here is just a code example.

<script>
    if (navigator.geolocation) {
                navigator.geolocation.getCurrentPosition(showPosition);
/*        navigator.geolocation.getCurrentPosition(showPosition, showError);*/
    } else { 
        alert("Geolocation is not supported by this browser.")
    }
</script>

All of a sudden It always denies tracing my location and when I click the trace icon it says

"The following sites have been blocked from tracking your location on this page <my page name>" 

And below it says

"Settings will be cleared on next reload"

I've tried to reload the page, I've tried to restart Google Chrome, I've entered in the location settings but the block list is empty so I can't find my page there either.

So what can I do? I can't continue to develop my page as long as my page is permanently blocked.

Share Improve this question asked Sep 22, 2017 at 10:20 Joey_DJoey_D 1171 silver badge7 bronze badges 3
  • 4 try removing auto fill form data and hosted app data from cache. Basically if you clicked once not to use the geolocation, it will capture it till the end. If that won't work then we need to find another issue. – Dhaval Jardosh Commented Sep 22, 2017 at 11:03
  • 6 Had the same issue which was driving me insane. What eventually fixed it was clearing hosted app data as Dhaval Jardosh suggested. Settings -> Advanced -> Clear Browsing Data -> Hosted App Data. – user3333134 Commented Nov 15, 2017 at 18:46
  • ok but when someone blocks my page to access his location and then decides to allow, will he have to go through all this steps to allow? for most people - not developers, just site visitors - is this too plicated I think. Any ideas? @user3333134 – Meir Commented Jun 3, 2020 at 19:53
Add a ment  | 

3 Answers 3

Reset to default 1

TL;DR: Settings > Clear Browsing Data > Advanced > check 'Hosted App Data' > Clear Data

Walkthrough:

  1. In Chrome, click the menu button and then 'Settings' (or just visit 'chrome://settings/').
  2. In Settings, start typing 'clear browsing data' into the search bar and select 'Clear browsing data' under 'Privacy and Security' when it appears.
  3. In the 'Clear Browsing Data' pop-up, click on the 'Advanced' tab.
  4. Set time range to 'Last hour' (or longer depending on when you think Chrome began to block geolocation).
  5. Check the 'Hosted app data' checkbox (it should be at the bottom of the list), and deselect all of the other checkboxes.
  6. Click 'Clear Data'.
  7. Go back to the page which is trying to request geolocation. The geolocation permission dialogue should appear next time you attempt to trigger it.

Further note:

For development work, you can override geolocation in Chrome DevTools. See the following article for instructions: https://developers.google./web/tools/chrome-devtools/device-mode/geolocation

> Open the Google Chrome app. Touch the Chrome menu . Touch Settings >
> Site settings > Location. Use the switch to either have Chrome ask
> before accessing your location, or to block all sites from accessing
> your location. Touch the specific blocked or allowed sites to manage
> exceptions.

try using microsoft edge than google chrome i use microsoft edge just to test my current browser location on localhost

发布评论

评论列表(0)

  1. 暂无评论