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

View in English Always switch to English

GeolocationPositionError

Baseline Widely available

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

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

GeolocationPositionError 介面表示使用地理定位裝置時發生錯誤的原因。

實例屬性

GeolocationPositionError 介面不繼承任何屬性。

GeolocationPositionError.code Read only

回傳一個 unsigned short,表示錯誤代碼。可能的值如下:

相關常數 描述
1 PERMISSION_DENIED 獲取地理定位訊息失敗,因為頁面沒有必要的權限,例如被權限政策阻擋。
2 POSITION_UNAVAILABLE 獲取地理定位失敗,因為至少一個內部位置來源回傳了內部錯誤。
3 TIMEOUT 在獲取到訊息之前,已達到獲取地理定位所允許的時間。
GeolocationPositionError.message Read only

回傳一個人類可讀的字串,描述錯誤的詳細資訊。規範指出,這主要用於除錯,不應直接顯示在使用者介面中。

實例方法

GeolocationPositionError 介面既不實作也不繼承任何方法。

規範

Specification
Geolocation
# position_error_interface

瀏覽器相容性

參見