问题描述
我想检查运行我的页面
的浏览器是否能够处理'html 5占位符'
I want to check if the browser who's running my page is capable of handling the 'html 5 placeholder'
我知道我可以添加以下内容javascript check:
I know I can add the following javascript check:
!Modernizr.input.placeholder
但是为一次检查导入库是否值得?
but is it worth to import a library just for one check ?
现代化者如何为我做这件事(我的意思是如何在封面下实施)?
also how does modernizr do that for me (i mean how is it implemented under the cover) ?
推荐答案
如果你想检查占位符
支持,那么你们所有的人需要做的是;
If you want to check for placeholder
support, then all you need to do is;
var placeholderSupport = "placeholder" in document.createElement("input");
并回答您的其他问题; 没有,绝对没有任何意义,包括整个Modernizr库的1行JS(Modernizr是1000多行....去图:))*
And to answer your other question; no, there is absolutely no point including the whole Modernizr library for 1 line of JS (Modernizr is 1000+ lines.... go figure :))*
这篇关于Modernizr只是一个快速检查?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!