BatteryManager
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Secure context: This feature is available only insecure contexts (HTTPS), in some or allsupporting browsers.
TheBatteryManager interface of theBattery Status API provides information about the system's battery charge level. Thenavigator.getBattery() method returns a promise that resolves with aBatteryManager interface.
Since Chrome 103, theBatteryManager interface ofBattery Status API only expose to secure context.
In this article
Instance properties
Also inherits properties from its parent interface,EventTarget.
BatteryManager.chargingRead onlyA Boolean value indicating whether the battery is currently being charged.
BatteryManager.chargingTimeRead onlyA number representing the remaining time in seconds until the battery is fully charged, or 0 if the battery is already fully charged.
BatteryManager.dischargingTimeRead onlyA number representing the remaining time in seconds until the battery is completely discharged and the system suspends.
BatteryManager.levelRead onlyA number representing the system's battery charge level scaled to a value between 0.0 and 1.0.
Instance methods
Also inherits methods from its parent interface,EventTarget.
Events
Also inherits events from its parent interface,EventTarget.
chargingchangeFired when the battery charging state (the
chargingproperty) is updated.chargingtimechangeFired when the battery charging time (the
chargingTimeproperty) is updated.dischargingtimechangeFired when the battery discharging time (the
dischargingTimeproperty) is updated.levelchangeFired when the battery level (the
levelproperty) is updated.
Specifications
| Specification |
|---|
| Battery Status API> # the-batterymanager-interface> |