如何使用特征检测来了解浏览器是否支持 border-radius? (包括IE9)
我见过很多使用类似以下内容来检测对边框半径的支持的示例:
var cssAttributeNames = ['BorderRadius', 'MozBorderRadius', 'WebkitBorderRadius', 'OBorderRadius', 'KhtmlBorderRadius'];
for (var i = 0; i < cssAttributeNames.length; i++) {
var attributeName = cssAttributeNames[i];
if (window.document.body.style[attributeName] !== undefined) {
this._useCss = true;
break;
}
}
但这似乎不适用于 IE9,它确实支持边框半径。我错过了什么吗?
I've seen plenty of examples for detecting support for border radius using something like:
var cssAttributeNames = ['BorderRadius', 'MozBorderRadius', 'WebkitBorderRadius', 'OBorderRadius', 'KhtmlBorderRadius'];
for (var i = 0; i < cssAttributeNames.length; i++) {
var attributeName = cssAttributeNames[i];
if (window.document.body.style[attributeName] !== undefined) {
this._useCss = true;
break;
}
}
But this doesn't seem to work for IE9, which does support border-radius. Am I missing something?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
明白了 - 检测数组需要添加“borderRadius” - 它区分大小写。
Got it - the detection array needs 'borderRadius' added - it's case-sensitive.
Modernizr 是一个用于检测 HTML5 功能(包括
border-radius
)的 Javascript 库,因此,如果您正在寻找现成的解决方案,请检查一下。Modernizr is a Javascript library used to detect HTML5 features (including
border-radius
), so if you're looking for a ready made solution, check that out.