This specification defines a means to receive events that correspond to changes in atmospheric pressure.

Introduction

The AtmPressureEvent interface provides web developers information about the atmospheric pressure levels measured at the hosting device.

This is achieved by interrogating a barometer or similar detectors of the hosting device. Not all devices contain a barometer, and when there is no barometer, this API is still exposed to the scripting environment but it does nothing.

Use Cases

Altitude sensing applications which make use of the relationship between changes in pressure relative to the altitude.

Weather prediction applications which make use of barometric pressure to predict weather conditions such as rain is coming.

Simple informative weather application that reports atmospheric pressure along with other data.

This specification defines conformance criteria that apply to a single product: the user agent that implements the interfaces that it contains.

Terminology

The EventHandler interface represents a callback function used for event handlers as defined in [[!HTML5]].

The concepts queue a task and fires a simple event are defined in [[!HTML5]].

The terms event handlers and event handler event types are defined in [[!HTML5]].

The concepts create an event and fire an event are defined in [[!DOM4]].

The current atmospheric pressure is a value that represents the force per unit area exerted onto the hosting device around the pressure sensor by the weight of air above that surface in the atmosphere of Earth in hPA (millibar).

Security and privacy considerations

Atmospheric Pressure

The HTML5 specification [[!HTML5]] defines a Window interface, which this specification extends:

attribute EventHandler onatmpressure

The onatmpressure event handler and its corresponding event handler event type atmpressure MUST be supported as an IDL attribute by all objects implementing the Window interface.

AtmPressureEvent Interface

readonly attribute double value
The current atmospheric pressure.
double value

When a user agent is required to fire an atmospheric pressure event, the user agent MUST run the following steps:

  1. Create an event that uses the AtmPressureEvent interface, with the name atmpressure, which bubbles, is not cancelable, and has no default action, that also meets the following conditions:
    1. If the implementation is unable to report the current atmospheric pressure, initialize the value attribute to positive Infinity, otherwise initialize the attribute to the current atmospheric pressure.
  2. Queue a task to dispatch the newly created event at the Window object.

When the current atmospheric pressure changes, the user agent MUST fire a atmospheric pressure event.

The definition of granularity i.e. how often the event is fired is left to the implementation. Implementations may fire the event if they have reason to believe that the page does not have sufficiently fresh data.

Event handlers

The following are the event handlers (and their corresponding event handler event types) that MUST be supported as attributes by the Window object:

event handler event handler event type
onatmpressure atmpressure