MediaQueryList - Web APIs | MDN

archived 4 Mar 2016 04:24:56 UTC
Creation of new accounts on MDN is unavailable until further notice. Sorry for the inconvenience! If you see something that needs to be fixed, please file a bug: https://bugzilla.mozilla.org/form.doc
Your Search Results

    MediaQueryList

    This is an experimental technology
    Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the specification changes.
    A MediaQueryList object maintains a list of media queries on a document, and handles sending notifications to listeners when the media queries on the document change.
    This makes it possible to observe a document to detect when its media queries change, instead of polling the values periodically, if you need to programmatically detect changes to the values of media queries on a document.

    Method overviewEdit

    void addListener(MediaQueryListListener listener);
    void removeListener(MediaQueryListListener listener);

    PropertiesEdit

    Property Type Description
    matches boolean true if the document currently matches the media query list; otherwise false. Read only.
    media DOMString The serialized media query list.

    MethodsEdit

    addListener()

    Adds a new listener to the media query list. If the specified listener is already in the list, this method has no effect.
    void addListener(
      MediaQueryListListener listener
    );

    Parameter (for addListener method)

    listener
    The MediaQueryListListener to invoke when the media query's evaluated result changes.

    removeListener()

    Removes a listener from the media query list. Does nothing if the specified listener isn't already in the list.
    void removeListener(
      MediaQueryListListener listener
    );

    Parameter (for removeListener method)

    listener
    The MediaQueryListListener to stop calling on changes to the media query's evaluated result.

    SpecificationsEdit

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

    Browser compatibilityEdit

    Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
    Basic support 9 6.0 (6.0) 10 12.1 5
    Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
    Basic support ? ? ? ? ?

    See alsoEdit

    Document Tags and Contributors

     Last updated by: cvrebert,
    0%
    10%
    20%
    30%
    40%
    50%
    60%
    70%
    80%
    90%
    100%