Magnetic Field Events
Introduction
This section is non-normative.
The DeviceMagneticFieldEvent interface provides web developers information about the magnetic field near the hosting device.
This is achieved by interrogating a magnetic field sensor or similar detectors of a device.
Use cases
Conformance
As well as sections marked as non-normative, all authoring guidelines, diagrams, examples, and notes in this specification are non-normative. Everything else in this specification is normative.
The key words must, must not, required, should, should not, recommended, may, and optional in this specification are to be interpreted as described in [RFC2119].
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].
Security and privacy considerations
Magnetic Field
The HTML5 specification [HTML5] defines a [Window] interface, which this specification extends:
partial interface Window {
attribute EventHandler ondevicemagneticfield;
};
Attributes
ondevicemagneticfield of type EventHandler
The ondevicemagneticfield event handler and its corresponding event handler event type devicemagneticfield must be supported as an IDL attribute by all objects implementing the Window interface.
DeviceMagneticFieldEvent Interface
[Constructor (DOMString type, optional DeviceMagneticFieldEventInit eventInitDict)]
interface DeviceMagneticFieldEvent : Event {
readonly attribute double x;
readonly attribute double y;
readonly attribute double z;
};
dictionary DeviceMagneticFieldEventInit : EventInit {
double x;
double y;
double z;
};
Attributes
x of type double, readonly
- Ambient magnetic field in the X axis.
y of type double, readonly
- Ambient magnetic field in the Y axis.
z of type double, readonly
- Ambient magnetic field in the Z axis.
Dictionary DeviceMagneticFieldEventInit Members
x of type double
y of type double
z of type double
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 |
| ondevicemagneticfield | devicemagneticfield |
References
[DOM4]
- Anne van Kesteren; Aryeh Gregor; Ms2ger. DOM4. URL: http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html/
[RFC2119]
- S. Bradner. Key words for use in RFCs to Indicate Requirement Levels. March 1997. Internet RFC 2119. URL: http://www.ietf.org/rfc/rfc2119.txt
[HTML5]
- Ian Hickson; David Hyatt. HTML5. 29 March 2012. W3C Working Draft. (Work in progress.) URL: http://www.w3.org/TR/html5