Syntax:
sysinfo.chargelevel = "batteryLevelChange()";
function batteryLevelChange() { // ... };
Description:
The onchargelevel
property is an event handler for the event of when the battery level is changed. The callback function is assigned by providing the function's name wrapped in a string.
For more general information on power consumption and widgets, see Saving battery time.
Example code:
window.onload = function(){ // Get the current battery level var batteryLevel = sysinfo.chargelevel; alert("Current battery level is " + batteryLevel + "%"); // Assign an even handler for the charge level change sysinfo.onchargelevel = "batteryLevelChange()"; } function batteryLevelChange() { var batteryLevel = sysinfo.chargelevel; alert("Current battery level is " + batteryLevel + "%"); }