The battery
read-only property returns a BatteryManager
which provides information about the system's battery charge level and whether the device is charging and exposes events that fire when these parameters change. This interface was introduced in early drafts of the Battery Status API and but has been replaced with Promise
-based Navigator.getBattery()
.
Syntax
var battery = navigator.battery;
Browser compatibility
| Desktop | Mobile |
---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | Android webview | Chrome for Android | Firefox for Android | Opera for Android | Safari on iOS | Samsung Internet |
---|
battery | Chrome
No support
20 — 29-
No support
20 — 29
- Prefixed Implemented with the vendor prefix: webkit
| Edge
No support
No | Firefox
No support
16 — 50-
No support
16 — 50
- Notes Removed in favor of
navigator.getBattery() . - Notes The Battery API was supported on Android, Windows, and Linux with UPower installed. Support for macOS was available starting with Firefox 18.
-
No support
11 — 16
- Prefixed Implemented with the vendor prefix: moz
-
No support
10 — 16
- Disabled From version 10 until version 16 (exclusive): this feature is behind the
dom.battery.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
| IE
No support
No | Opera
No support
No | Safari
No support
No | WebView Android
No support
No | Chrome Android
No support
No | Firefox Android
No support
16 — 50-
No support
16 — 50
- Notes Removed in favor of
navigator.getBattery() . - Notes The Battery API was supported on Android, Windows, and Linux with UPower installed. Support for macOS was available starting with Firefox 18.
-
No support
14 — 16
- Prefixed Implemented with the vendor prefix: moz
-
No support
10 — 16
- Disabled From version 10 until version 16 (exclusive): this feature is behind the
dom.battery.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
| Opera Android
No support
No | Safari iOS
No support
No | Samsung Internet Android
No support
No |
---|
Legend
-
No support
- No support
- Deprecated. Not for use in new websites.
- Deprecated. Not for use in new websites.
- See implementation notes.
- See implementation notes.
- User must explicitly enable this feature.
- User must explicitly enable this feature.
- Requires a vendor prefix or different name for use.
- Requires a vendor prefix or different name for use.
See also