Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. Magnetometer
  4. Magnetometer()

Magnetometer: Magnetometer() constructor

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Secure context: This feature is available only insecure contexts (HTTPS), in some or allsupporting browsers.

Experimental:This is anexperimental technology
Check theBrowser compatibility table carefully before using this in production.

TheMagnetometer() constructorcreates a newMagnetometer object which returns information about themagnetic field as detected by a device's primary magnetometer sensor.

Syntax

js
new Magnetometer()new Magnetometer(options)

Parameters

optionsOptional

Options are as follows:

frequencyOptional

The desired number of times per second a sample shouldbe taken, meaning the number of times per second that thereading event will be called. A whole number or decimal may beused, the latter for frequencies less than a second. The actual reading frequencydepends on device hardware and consequently may be less than requested.

referenceFrameOptional

Either'device' or'screen'. The default is'device'.

Exceptions

SecurityErrorDOMException

Use of this feature was blocked by aPermissions Policy.

Specifications

Specification
Magnetometer
# dom-magnetometer-magnetometer

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp