0

Here's the snippet that fails with "invalid argument" in IE10. Works for Chrome, FF but fails for IE. I am just debugging a js issue and came across this. I dont have any prior knowledge about matchMedia or nor i am a CSS expert. Please excuse my ignorance if any.

win.matchMedia("")
4

1 回答 1

0

我也刚遇到这种情况。这是 IE10-11 中的不一致行为。我的解决方案是在我的应用程序中实现方法,该方法在调用 matchMedia.matches() 之前首先检查空字符串...根据上下文,您可能会执行以下操作:

if(meqia_query === "" || matchMedia.matches(media_query)) {
  // do your thing
}

或者

function myMatchMedia(media_query) {
  return (meqia_query === "" || matchMedia.matches(media_query));
}
于 2014-05-08T22:01:54.660 回答