Version: Smart Feature Phone 2.5

BatteryManager.onbatteryhealthchange

Specifies an event listener to receive batteryhealthchange events. These events occur when the battery health state is updated.

Syntax#

battery.onbatteryhealthchange = funcRef

Where battery is a BatteryManager object, and funcRef is a function to be called when the batteryhealthchange event occurs.

Example#

HTML Content#

<div id="health">(battery health unknown)</div>

JavaScript Content#

navigator.getBattery().then(function(battery) {
battery.onbatteryhealthchange = batteryhealthchange();
function batteryhealthchange() {
document.querySelector('#health').textContent = battery.health;
}
});