MediaQueryListEvent.MediaQueryListEvent()

The MediaQueryListEvent constructor creates a new MediaQueryListEvent instance.

Syntax

var myMqlEvent = new MediaQueryListEvent(init);

Parameters

init

An init object that defines features of the new object instance. The available properties are:

  • media: A DOMString representing a serialized media query.
  • matches: A Boolean representing the media query status — true if it matches, false if not.

Examples

var media = '(max-width: 600px)';
var matches = true;

var myMediaQueryListEvent = new MediaQueryListEvent({media, matches});

Specifications

Specification Status Comment
CSS Object Model (CSSOM) View Module
The definition of 'MediaQueryListEvent()' in that specification.
Working Draft Initial definition

Browser compatibility

DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
MediaQueryListEvent() constructorChrome Full support YesEdge Full support ≤79Firefox Full support 55IE No support NoOpera Full support YesSafari ? WebView Android No support NoChrome Android Full support YesFirefox Android Full support 55Opera Android Full support YesSafari iOS ? Samsung Internet Android Full support Yes

Legend

Full support
Full support
No support
No support
Compatibility unknown
Compatibility unknown

See also