getBattery method

JSPromise<BatteryManager> getBattery()

The getBattery() method provides information about the system's battery. It returns a battery promise, which resolves with a BatteryManager object providing some properties to get the battery status also some events you can handle to monitor the battery status. This implements the Battery Status API; see that documentation for additional details, a guide to using the API, and sample code.

Since Chrome 103, the Navigator.getBattery() method of Battery Status API only expose to secure context.

Note: Access to this feature may be controlled by the directive .

Implementation

external JSPromise<BatteryManager> getBattery();