-1

我正在按照附件运行一个非常简单的 enquire.js 测试,发现它没有得到 IE9 的响应。其他几个浏览器响应良好(FF、Chrome、Safari)。我已经在 IE9 中测试了来自 GITHUB 的测试套件,它运行良好——所以我一定遗漏了一些东西。任何帮助表示赞赏!

<!doctype html>
<html>
 <head>
  <meta charset="utf-8">
  <title>enquire.js test</title>
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width">
</head>
<body>
 <div id="frame">hello</div>
 <script src="js/libs/jquery.1.7.1.js"></script>
 <script src="../dist/enquire.js"></script>
 <script>
  $(document).ready(function(){
enquire.listen(50);
enquire.register("screen and (max-width: 1000px)",
      {
       match : function(){
  $("#frame").css("background-color","#f00");
       },     
       unmatch : function(){
  $("#frame").css("background-color","#0f0");
 },    
     });
   });
 </script>
</body>
</html>
4

1 回答 1

3

IE9 does not support the matchMedia API so you have to include a polyfill to get it to work. You can add the polyfill to the page however you like, providing it's loaded before enquire. Personally I use Modernizr to conditionally load polyfills, but that's personal preference.

Hope that helps

于 2013-01-27T20:34:03.230 回答