on
Italy
- Get link
- X
- Other Apps
navigator.battery. Particularly for mobile devices I can see this being really useful.navigator.battery
{
charging: true,
chargingTime: 0,
dischargingTime: Infinity,
level: 1,
onchargingchange: null,
onchargingtimechage: null,
ondischargingtimechange: null,
onlevelchange: null
}
You will notice a number of events that you can bind tonavigator.battery.onchargingchange = function () {
console.log(navigator.battery.charging);
}
navigator.battery.onchargingtimechange = function () {
console.log(navigator.battery.chargingTime);
}
navigator.battery.oncdischargingtimechange = function () {
console.log(navigator.battery.dischargingTime);
}
navigator.battery.onlevelchange = function () {
console.log(navigator.battery.level);
}
You could use these to update graphics or change application behaviour when battery life or status changes.navigator.battery or navigator.webkitBattery.
I found that my version of Firefox (26.0) is supported but only default
values are returned so the browser isn't able to read battery status.
Comments
Post a Comment