此頁面由社群從英文翻譯而來。了解更多並加入 MDN Web Docs 社群。

View in English Always switch to English

Navigator:geolocation 屬性

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2015年7月⁩.

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

Navigator.geolocation 唯讀屬性會回傳一個 Geolocation 物件,讓 Web 內容能存取裝置的位置。這允許網站或應用程式根據使用者的位置提供自訂的結果。

備註:基於安全考量,當網頁嘗試存取位置資訊時,會通知使用者並要求授權。請注意,每個瀏覽器都有其請求此權限的政策與方法。