搜尋 Mozilla 技術支援網站

防止技術支援詐騙。我們絕對不會要求您撥打電話或發送簡訊,或是提供個人資訊。請用「回報濫用」功能回報可疑的行為。

Learn More

Firefox not returning current location.

  • 4 回覆
  • 2 有這個問題
  • 103 次檢視
  • 最近回覆由 cor-el

more options

I want to get my current location in my website, I am using this function navigator.geolocation.getCurrentPosition(function(position){}) it is working fine on all browsers but it is not working on firefox. If firefox use some different techniques as compare to different browsers to have current location than please let me know. Thanks

I want to get my current location in my website, I am using this function navigator.geolocation.getCurrentPosition(function(position){}) it is working fine on all browsers but it is not working on firefox. If firefox use some different techniques as compare to different browsers to have current location than please let me know. Thanks

被選擇的解決方法

Try the Firefox version from the official Mozilla server if you currently use a version from the repositories of your Linux distribution to see if that version behaves differently.

從原來的回覆中察看解決方案 👍 0

所有回覆 (4)

more options

Could I point you toward Mozilla's documentation: https://developer.mozilla.org/docs/Web/API/Geolocation

Note: In Firefox 55 and higher, only HTTPS pages will be able to request location.

To make sure Firefox is not disabled from responding to sites' requests for location, you can check here:

(1) In a new tab, type or paste about:config in the address bar and press Enter/Return. Click the button promising to be careful.

(2) In the search box above the list, type or paste geo. and pause while the list is filtered

(3) If the geo.enabled preference is bolded and "user set" to false, double-click it to restore the default value of true

more options

it is already true.

more options

Okay, so by default Firefox should prompt you when the site wants to access your location. Could you check the Permissions panel of the Page Info dialog to see whether a non-default permission has been saved for the page. While you are on the page that is going to call that API, you can open the dialog using any of these:

  • right-click a blank area of the page and choose View Page Info > Permissions
  • (menu bar) Tools menu > Page Info > Permissions
  • click the padlock or "i" icon to the left of the site address, then the ">" icon, then More Information > Permissions

Scroll down to "Access Your Location" and the gray or black dot indicates the current permission for the site. (It's gray if Use default is checked, black if it has been customized.)

Anything unusual there? If that allows access, it could be your code, or it could be some other factor.

If a site is generally known to work in Firefox, these are general suggestions to try when it stops working:

Cache and Cookies: When you have a problem with one particular site, a good "first thing to try" is clearing your Firefox cache and deleting your saved cookies for the site.

(1) Clear Firefox's Cache

See: How to clear the Firefox cache

If you have a large hard drive, this might take a few minutes. If you do not see the number going down on the page, you can reload it using Ctrl+r to check progress.

(2) Remove the site's cookies (save any pending work first). While viewing a page on the site, try either:

  • right-click (on Mac Ctrl+click) a blank area of the page and choose View Page Info > Security > "View Cookies"
  • (menu bar) Tools > Page Info > Security > "View Cookies"
  • click the padlock or "i" icon in the address bar, then the ">" button, then More Information, and finally the "View Cookies" button

In the dialog that opens, the current site should be pre-filled in the search box at the top of the dialog so you can remove that site's cookies individually.

Then try reloading the page. Does that help?

Testing in Firefox's Safe Mode: In Safe Mode, Firefox temporarily deactivates extensions, hardware acceleration, and some other advanced features to help you assess whether these are causing the problem.

If Firefox is not running: Hold down the Shift key when starting Firefox.

If Firefox is running: You can restart Firefox in Safe Mode using either:

  • "3-bar" menu button > "?" button > Restart with Add-ons Disabled
  • Help menu > Restart with Add-ons Disabled

and OK the restart.

Both scenarios: A small dialog should appear. Click "Start in Safe Mode" (not Refresh).

Any improvement? (More info: Diagnose Firefox issues using Troubleshoot Mode)

more options

選擇的解決方法

Try the Firefox version from the official Mozilla server if you currently use a version from the repositories of your Linux distribution to see if that version behaves differently.