The BatteryManager interface of the Battery Status API provides information about the system's battery charge level. The navigator.getBattery() method returns a promise that resolves with a BatteryManager interface.
On this page
BatteryManager
Instance properties
BatteryManager.chargingRead only-
A Boolean value indicating whether the battery is currently being charged.
BatteryManager.chargingTimeRead only-
A number representing the remaining time in seconds until the battery is fully charged, or 0 if the battery is already fully charged.
BatteryManager.dischargingTimeRead only-
A number representing the remaining time in seconds until the battery is completely discharged and the system suspends.
BatteryManager.levelRead only-
A number representing the system's battery charge level scaled to a value between 0.0 and 1.0.
Instance methods
Inherits methods from its parent interface: EventTarget.
Events
-
chargingchange -
Fired when the battery charging state (the
chargingproperty) is updated. -
chargingtimechange -
Fired when the battery charging time (the
chargingTimeproperty) is updated. -
dischargingtimechange -
Fired when the battery discharging time (the
dischargingTimeproperty) is updated. -
levelchange -
Fired when the battery level (the
levelproperty) is updated.
Specifications
| Specification |
|---|
| Battery Status API # the-batterymanager-interface |
Browser compatibility
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
BatteryManager |
38 | 79 | 43–52 | No | 25 | No | 38 | 38 | 43–52 | 25 | No | 3.0 |
charging |
38 | 79 | 43–52 | No | 25 | No | 38 | 38 | 43–52 | 25 | No | 3.0 |
chargingTime |
38 | 79 | 43–52 | No | 25 | No | 42
38–42Always equal to0 or Infinity.
|
42
38–42Always equal to0 or Infinity.
|
43–52 | 29
25–29Always equal to0 or Infinity.
|
No | 4.0
3.0–4.0Always equal to0 or Infinity.
|
chargingchange_event |
38 | 79 | 43–52 | No | 25 | No | 38 | 38 | 43–52 | 25 | No | 3.0 |
chargingtimechange_event |
38 | 79 | 43–52 | No | 25 | No | 38 | 38 | 43–52 | 25 | No | 3.0 |
dischargingTime |
38 | 79 | 43–52 | No | 25 | No | 42
38–42Always equal toInfinity.
|
42
38–42Always equal toInfinity.
|
43–52 | 29
25–29Always equal toInfinity.
|
No | 4.0
3.0–4.0Always equal toInfinity.
|
dischargingtimechange_event |
38 | 79 | 43–52 | No | 25 | No | 38 | 38 | 43–52 | 25 | No | 3.0 |
level |
38 | 79 | 43–52 | No | 25 | No | 38 | 38 | 43–52 | 25 | No | 3.0 |
levelchange_event |
38 | 79 | 43–52 | No | 25 | No | 38 | 38 | 43–52 | 25 | No | 3.0 |
secure_context_required |
103 | 103 | No | No | No | No | 103 | 103 | No | 71 | No | 20.0 |
See also
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/BatteryManager