简体   繁体   English

IE9中的enquire.js没有响应

[英]enquire.js not responsive in IE9

I'm running a very simple enquire.js test as per the enclosed and finding that it doesn't get a response from IE9. 我按照所附文件运行了一个非常简单的enquire.js测试,发现它没有收到IE9的响应。 Several other browsers are responding fine (FF, Chrome, Safari). 其他几种浏览器的响应都很好(FF,Chrome,Safari)。 I've tested the test-suite from GITHUB in IE9 which runs fine - so I must be missing something. 我已经在IE9中测试了GITHUB的测试套件,该套件运行良好-所以我肯定缺少一些东西。 Any help appreciated! 任何帮助表示赞赏!

<!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>

IE9 does not support the matchMedia API so you have to include a polyfill to get it to work. IE9不支持matchMedia API ,所以你必须包括填充工具得到它的工作。 You can add the polyfill to the page however you like, providing it's loaded before enquire. 您可以根据需要将polyfill添加到页面中,前提是在查询之前已将其加载。 Personally I use Modernizr to conditionally load polyfills, but that's personal preference. 我个人使用Modernizr来有条件地加载polyfills,但这是个人喜好。

Hope that helps 希望能有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM