The BatteryManager interface provides ways to get information about the system's battery charge level.

Documentation BatteryManager by Mozilla Contributors, licensed under CC-BY-SA 2.5.

See also:

Variables

read onlycharging:Bool

A Boolean value indicating whether or not the battery is currently being charged.

read onlychargingTime:Float

A number representing the remaining time in seconds until the battery is fully charged, or 0 if the battery is already fully charged.

read onlydischargingTime:Float

A number representing the remaining time in seconds until the battery is completely discharged and the system will suspend.

read onlylevel:Float

A number representing the system's battery charge level scaled to a value between 0.0 and 1.0.

onchargingchange:Function

A handler for the chargingchange event; This event is sent when the battery charging state is updated.

onchargingtimechange:Function

A handler for the chargingtimechange event; This event is sent when the battery charging time is updated

ondischargingtimechange:Function

A handler for the dischargingtimechange event; This event is sent when the battery discharging time is updated.

onlevelchange:Function

A handler for the levelchange event; This event is sent when the battery level is updated.

Inherited Variables

Inherited Methods

Defined by EventTarget

addEventListener(type:String, listener:Function, ?options:EitherType<AddEventListenerOptions, Bool>, ?wantsUntrusted:Bool):Void

addEventListener(type:String, listener:EventListener, ?options:EitherType<AddEventListenerOptions, Bool>, ?wantsUntrusted:Bool):Void

Register an event handler of a specific event type on the EventTarget.

Throws:

null

DOMError

dispatchEvent(event:Event):Bool

Dispatch an event to this EventTarget.

Throws:

null

DOMError

removeEventListener(type:String, listener:Function, ?options:EitherType<EventListenerOptions, Bool>):Void

removeEventListener(type:String, listener:EventListener, ?options:EitherType<EventListenerOptions, Bool>):Void

Removes an event listener from the EventTarget.

Throws:

null

DOMError