Movatterモバイル変換


[0]ホーム

URL:


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

RTCDataChannelEvent: RTCDataChannelEvent() constructor

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨January 2020⁩.

TheRTCDataChannelEvent() constructorcreates a newRTCDataChannelEvent object.

Note:You will rarely if ever construct anRTCDataChannelEvent by hand; theseevents are normally created and sent by the WebRTC layer itself.

Syntax

js
new RTCDataChannelEvent(type, options)

Parameters

type

A string with the name of the event.It is case-sensitive and browsers always set it todatachannel.

options

An object that,in addition of the properties defined inEvent(), can have the following properties:

channel

ARTCDataChannel, representing the data channel being associated with the event.

Return value

A newRTCDataChannelEvent object configured as specified.

Example

In this example, a newdatachannel event is created.dc is adata channel which already exists.

js
const event = new RTCDataChannelEvent("datachannel", { channel: dc });

Specifications

Specification
WebRTC: Real-Time Communication in Browsers
# dom-rtcdatachannelevent-constructor

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp