javascript Modernizr 检查以检测 Firefox
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11318389/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Modernizr checks to detect firefox
提问by Natto
What are the possible checks can be made to detect firefox features using modernizr?
可以进行哪些检查来使用 Modernizr 检测 Firefox 功能?
回答by pdjota
Even if browser detection is not recommended for features it could be use to present other type of information.
即使不建议对功能进行浏览器检测,它也可以用于呈现其他类型的信息。
Modernizr.addTest('firefox', function () {
return !!navigator.userAgent.match(/firefox/i);
});
This adds a class .firefox to document.documentElement (html tag)
这将一个类 .firefox 添加到 document.documentElement(html 标签)
回答by pdjota
Browser detection is unfortunately still necessary for things like video and audio since all browsers promote different formats. I think you'll find your answer here, Natto:
不幸的是,浏览器检测对于视频和音频等内容仍然是必要的,因为所有浏览器都提倡不同的格式。我想你会在这里找到答案,纳豆: