BatteryManager.charging
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
La propriété BatteryManager.charging
est une valeur booléenne indiquant si la batterie de l'équipement est en train d'être chargée. Lorsque sa valeur change, l'évènement chargingchange
est déclenché.
Si la batterie est en charge, la variable a la valeur true
. Sinon, dans le cas de la décharge, la variable vaut false
.
Exemple
HTML
html
<div id="charging">(état de charge inconnu)</div>
JavaScript
js
navigator.getBattery().then((battery) => {
const charging = battery.charging;
document.querySelector("#charging").textContent = charging;
});
Résultat
must be provided
Spécifications
Specification |
---|
Battery Status API # dom-batterymanager-charging |
Compatibilité des navigateurs
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
charging |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.