简体   繁体   中英

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. Several other browsers are responding fine (FF, Chrome, Safari). I've tested the test-suite from GITHUB in IE9 which runs fine - so I must be missing something. 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. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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