EN
이 콘텐츠는 한국어로 제공되지 않아 영어 버전으로 표시됩니다.

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

 

 

표시:
© 2014 Microsoft. All rights reserved.