简体   繁体   English

enquire.js遗产支持

[英]enquire.js legacy support

I'm trying to figure out what the best way to get enquire.js to work on legacy browsers (ie 6-9). 我试图找出让enquire.js在遗留浏览器上工作的最佳方法(即6-9)。 On enquire's site, it says to use modernizr to check for matchMedia support, then load a polyfill if it's not supported. 在查询的网站上,它说使用modernizr检查matchMedia支持,然后加载polyfill,如果它不受支持。

Modernizr.load([
    //first test need for polyfill
    {
        test: window.matchMedia,
        nope: "/path/to/polyfill.js"
    },

    //and then load enquire
    "/path/to/enquire.js"
]);

Looking at the polyfill that it suggests, it says that modernizr already includes it with Modernizr.mq(). 看看它建议的polyfill,它说modernizr已经将它包含在Modernizr.mq()中。

    Used in:
    Respond.js
    FormFactor
    Modernizr
https://github.com/paulirish/matchMedia.js/

I've looked into this, but can't find a way to make this work. 我已经调查了这个,但找不到让这项工作的方法。

enquire author here! 在这里查询作者!

So there's always a little confusion about the matchMedia polyfill. 所以matchMedia polyfill总是有点混乱。 It doesn't polyfill CSS3 media query support into legacy browsers. 它不会将CSS3媒体查询支持填充到旧版浏览器中。 What it does is polyfill the matchMedia javascript API for those browsers that support CSS3 media queries but do not offer this API. 它的作用是为那些支持CSS3媒体查询但不提供此API的浏览器填充matchMedia javascript API。 See here for support for matchMedia . 请参阅此处以获取matchMedia的支持 For instance, IE9 supports CSS3 media queries, but doesn't have the matchMedia JS API, this is the target of Paul Irish's matchMedia polyfill. 例如,IE9支持CSS3媒体查询,但没有matchMedia JS API,这是Paul Irish的matchMedia polyfill的目标。

If you're looking for a fully featured polyfill, that gives decent media query suport to older browsers, can I suggest using David Knight's media-match? 如果你正在寻找一个功能齐全的polyfill,它可以为老版浏览器提供合适的媒体查询支持,我可以建议使用David Knight的媒体匹配吗? I have worked in conjunction with him to test this and have proven support all the way back to IE6 - it works a charm :) You can find that here: https://github.com/weblinc/media-match . 我和他一起工作来测试这个并且已经证明支持一直回到IE6 - 它有点魅力:)你可以在这里找到: https//github.com/weblinc/media-match You can conditionally load it exactly as I suggested with Modernizr, just replace the appropriate parts. 您可以完全按照我对Modernizr的建议有条件地加载它,只需更换相应的部件即可。

Hope that helps, happy to answer any further questions you have. 希望有所帮助,乐于回答您的任何进一步问题。

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

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