0

我有这段代码在 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) { ... };
4

1 回答 1

5

这取决于你想用 IE8 发生什么。如果你只是想让它运行桌面处理程序,那么改变你的代码:

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

选项“ trueshouldDegrade”告诉inquire 将媒体查询视为始终匹配不支持的浏览器(IE8 不支持CSS3 媒体查询)。这在http://wicky.nillia.ms/enquire.js/#delving-deeper的“移动优先”标题下进行了介绍

或者,如果您想要完全支持 IE8,您将不得不使用更高级的matchMediapolyfill。此处介绍了您的 polyfill 选项:http ://wicky.nillia.ms/enquire.js/#legacy-browsers

请再次阅读文档,因为您似乎错过了一些重要的点:)

于 2013-12-02T15:50:35.470 回答