2013-11-24 23 views
0

我有這樣的代碼不IE8的工作... Googleing身邊,我不能找到一個解決辦法...Enquire.js和IE8

你確切地知道我怎樣才能讓它在IE8的工作,以及?

下面是簡單的代碼(臺式機,平板電腦和移動與媒體查詢字符串變量...):

enquire.register(desktop, { 
       match: function() { 
        animate(a, b); 
       } 
      }).register(tablet, { 
       match: function() { 
        animate(a, b); 
       } 
      }).register(mobile, { 
       match: function() { 
        animate(a, b); 
       } 
      }); 

function animate(a, b) { ... }; 
+0

也許這可以幫助您:https://github.com/WickyNilliams/enquire。 js/issues/4 – aldanux

+0

我看了一下,但我仍然不明白如何讓它工作。 –

+0

我遇到同樣的問題。我已經嘗試在我的EnquireJS腳本之前添加國旗和Paul Irish填充腳本。還沒有運氣。在匹配的媒體查詢中IE9仍然不遵守JS。 – jthomas

回答

5

這取決於你想與IE8發生什麼。如果你只是希望它這樣運行桌面處理器,然後改變你的代碼:

enquire.register(desktop, { 
    match: function() { 
    animate(a, b); 
    } 
}, true) // note the true here 

true選項,「shouldDegrade」,告訴來電諮詢一如既往對待媒體查詢不能瀏覽器匹配(IE8是無能的CSS3媒體查詢)。這是標題下覆蓋「移動先行」這裏http://wicky.nillia.ms/enquire.js/#delving-deeper

另外,如果你想完全支持IE8你將不得不使用更先進的matchMedia填充工具。您的polyfilling選項這裏介紹:http://wicky.nillia.ms/enquire.js/#legacy-browsers

請再次閱讀文檔,你似乎已經錯過了一些重要的點:)