Obsolete
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.
The chargingtimechange
event is fired when the chargingTime
attribute of the battery API has changed.
BatteryManager
The event callback doesn't receive any event objects, but properties can be read from the BatteryManager
object received from the navigator.getBattery
method.
Property | Type | Description |
---|---|---|
BatteryManager.chargingTime | double (float) | The remaining time in seconds until the system's battery is fully charged. Returns 0 if the battery is fully charged. Returns positive infinity, if the battery is discharging or if the implementation is unable to report the remaining charging time. Read only. |
navigator.getBattery().then(function(battery) { console.log("Battery charging time: " + battery.chargingTime + " seconds"); battery.addEventListener('chargingtimechange', function() { console.log("Battery charging time: " + battery.chargingTime + " seconds"); }); });
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/Events/chargingtimechange