使用 Javascript 检测浏览器是否支持 Web 开放字体格式 (Woff)
我必须使用 JS (jQuery) 检测浏览器是否支持 Woff,然后向主体添加一个类。 像这样的事情:
if(woffIsSupported){
$('body').addClass('modern');
}
这有可能吗?谢谢您的回答。
i have to detect with JS (jQuery) wether a browser supports Woff and then add a class to the body.
Something like this:
if(woffIsSupported){
$('body').addClass('modern');
}
is this somehow possible? Thank you for your answers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这篇文章上有一个名为
isFontFaceSupported
的函数根据浏览器功能检查支持(好方法,即不依赖用户代理字符串)。复制该函数,您的代码可以变为:
这是帖子中的函数:
There's a function on this post called
isFontFaceSupported
that checks for support based on browser features (the good way, i.e. not relying on the user agent string).Copy that function and your code can become:
Here is the function from the post:
因为很难测试我是否只使用浏览器检测:
它与用法匹配:http://caniuse。 com/#feat=woff
Because it's hard to test that I'm using just the browser detection:
It matches the usage: http://caniuse.com/#feat=woff