Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. NDEFMessage
  4. records

NDEFMessage: records property

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.

Therecords property ofNDEFMessage interface represents a list ofNDEFRecordspresent in the NDEF message.

Value

A list ofNDEFRecord object that represent data recorded in the message.

Examples

The following example shows how to read the contents of an NDEF message. It first sets up an event handler foronreading, which is passed an instance ofNDEFReadingEvent. AnNDEFMessage object is returned fromNDEFReadingEvent.message. It loops throughmessage.records and processes each record based on its message type. The data member is aDataView, which allows handling data encoded inUTF-16.

js
ndefReaderInst.onreading = (event) => {  const ndefMessage = event.message;  for (const record of ndefMessage.records) {    console.log(`Record type:  ${record.recordType}`);    console.log(`MIME type:    ${record.mediaType}`);    console.log(`Record id:    ${record.id}`);    switch (record.recordType) {      case "text":        // TODO: Read text record with record data, lang, and encoding.        break;      case "url":        // TODO: Read URL record with record data.        break;      default:      // TODO: Handle other records with record data.    }  }};

Specifications

Specification
Web NFC
# dom-ndefmessage-records

Browser compatibility

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp