Syntax:
sysinfo.onchargerconnected = "chargerConnectedEventHandler()"; function chargerConnectedEventHandler() { // ... }
Description:
The onchargerconnected
property is an event handler for the event of when the charger is plugged to or unplugged from the device.
Since the event is fired off much faster than the value is updated, it is recommended to read the value after a small delay. See example code for illustration.
For more general information on power consumption and widgets, see Saving battery power.
Example code:
window.onload = function(){ // Assign an even handler for the charger sysinfo.onchargerconnected = "chargerConnectedEvent()"; } function chargerConnectedEvent() { setTimeout("readValue();", 500); } function readValue() { if (sysinfo.chargerconnected) alert("Charger is connected"); else alert("Charger is not connected"); }