admin 管理员组文章数量: 1086019
I'm looking at modernizr which is supposed to help with feature detection which is supposedly the bees knees in figuring out if your website is patible with a given web browser but I do not see anything that indicates that I can use it to detect custom HTML elements that we create & define in our content.
If it's not modernizr, how do I reliably detect whether a browser is capable of handling custom HTML elements the "HTML 5" way?
I'm looking at modernizr which is supposed to help with feature detection which is supposedly the bees knees in figuring out if your website is patible with a given web browser but I do not see anything that indicates that I can use it to detect custom HTML elements that we create & define in our content.
If it's not modernizr, how do I reliably detect whether a browser is capable of handling custom HTML elements the "HTML 5" way?
Share Improve this question asked Aug 2, 2014 at 15:46 thisthis 1,42612 silver badges23 bronze badges 3- You really don't have to. If you include the code that makes old versions of IE work properly, then your non-standard elements will work on all modern browsers. It's a questionable practice, however, to do that anyway. – Pointy Commented Aug 2, 2014 at 15:48
- 1 Let me clarify - the intention is to not support old versions and notify users that they need to upgrade the browsers. We have no intention of supporting older browsers. – this Commented Aug 2, 2014 at 16:40
- Ah. Well I'm not sure how you'd check for that; there are probably different things that happen in different old browsers when an unknown tag is encountered. – Pointy Commented Aug 2, 2014 at 16:55
2 Answers
Reset to default 9Modernizr doesn't have a test for this at the moment, however since it has an API to create the element, it should be as simple as
var supportsCustomElements = ('registerElement' in document)
to detect for v0 of the API. To check for the more up to date v1, its
var supportsCustomElements = ('customElements' in window)
(more info on the in
operator)
Old thread, but just wanted to say that Modernizer is supporting it now.
本文标签: javascripthow to detect if browsers support custom elementsStack Overflow
版权声明:本文标题:javascript - how to detect if browsers support custom elements - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1744064583a2527351.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论