Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

matchMedia method

Accepts a string containing one or more media queries, and returns a MediaQueryList object.

Internet Explorer 10

 

Syntax

var retVal = Window.matchMedia(mediaQuery);

Parameters

mediaQuery [in]

Type: DOMString

retVal [out, retval]

Type: MediaQueryList

Standards information

Remarks

The following example creates a media query that checks whether the width or height of a window is less than a certain size.

Examples


mql = window.matchMedia("(min-height:250px)");
mql.addListener(sizeChange);
function sizeChange(mql) {
    v = document.getElementById("myDiv");
    if (mql.matches) {
        v.innerHTML = "getting big" + "<br/>" + mql.media;
    } else {
        v.innerHTML = "getting small" + "<br/>"+ mql.media;
    }
}


See also

Window

 

 

Show:
© 2017 Microsoft