Navigator.battery

  • Revision slug: Web/API/window.navigator.battery
  • Revision title: window.navigator.battery
  • Revision id: 410201
  • Created:
  • Creator: Jeremie
  • Is current revision? No
  • Comment

Revision Content

{{ domref() }}

Summary

The battery object provides information about the system's battery charge level; you can also listen to events it sends that provide updates about the battery's charge status. This implements the Battery Status API; see that documentation for additional details, a guide to using the API, and sample code.

Syntax

var battery = window.navigator.battery;

Value

navigator.battery is a {{domxref("BatteryManager")}} object.

Specifications

{{page("/en-US/docs/Web/API/BatteryManager","Specifications")}}

Browser compatibility

{{page("/en-US/docs/Web/API/BatteryManager","Browser_compatibility")}}

See also

Revision Source

<p>{{ domref() }}</p>
<h2>Summary</h2>
<p>The <code>battery</code> object provides information about the system's battery charge level; you can also listen to events it sends that provide updates about the battery's charge status. This implements the <a href="/en-US/docs/WebAPI/Battery_Status" title="/en-US/docs/WebAPI/Battery_Status">Battery Status API</a>; see that documentation for additional details, a guide to using the API, and sample code.</p>
<h2 id="Syntax" name="Syntax">Syntax</h2>
<pre class="syntaxbox">
var battery = window.navigator.battery;</pre>
<h2 id="Specifications">Value</h2>
<p><code>navigator.battery</code> is a {{domxref("BatteryManager")}} object.</p>
<h2>Specifications</h2>
<p>{{page("/en-US/docs/Web/API/BatteryManager","Specifications")}}</p>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<p>{{page("/en-US/docs/Web/API/BatteryManager","Browser_compatibility")}}</p>
<h2 id="See_also">See also</h2>
<ul>
  <li>{{domxref("BatteryManager")}}</li>
  <li>the <a href="/en-US/docs/WebAPI/Battery_Status" title="/en-US/docs/WebAPI/Battery_Status">Battery Status API</a> article</li>
  <li><a class="external" href="http://hacks.mozilla.org/2012/02/using-the-battery-api-part-of-webapi/">Blog post - Using the Battery API</a></li>
  <li><a class="external" href="http://davidwalsh.name/battery-api" title="http://davidwalsh.name/battery-api">David Walsh on the JavaScript Battery Api</a></li>
  <li><a href="https://github.com/pstadler/battery.js" title="https://github.com/pstadler/battery.js">battery.js - a tiny cross-browser wrapper</a></li>
</ul>
Revert to this revision